0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Lazyloaded @extractus/oembed-extractor dependency

- this dependency seems a pretty heavy one to require upon boot and
  given most sites don't need it to function as normal, this saves
  several MB of RAM per instance
This commit is contained in:
Daniel Lockyer 2023-05-09 14:30:38 +02:00 committed by Daniel Lockyer
parent 7639b7b69e
commit 898b55265c
2 changed files with 6 additions and 2 deletions

View file

@ -1,4 +1,3 @@
const {extract} = require('@extractus/oembed-extractor');
const logging = require('@tryghost/logging');
/**
@ -39,6 +38,8 @@ class TwitterOEmbedProvider {
return null;
}
const {extract} = require('@extractus/oembed-extractor');
/** @type {object} */
const oembedData = await extract(url.href);

View file

@ -1,7 +1,6 @@
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const logging = require('@tryghost/logging');
const {extract, hasProvider} = require('@extractus/oembed-extractor');
const cheerio = require('cheerio');
const _ = require('lodash');
const charset = require('charset');
@ -19,6 +18,8 @@ const messages = {
* @returns {{url: string, provider: boolean}}
*/
const findUrlWithProvider = (url) => {
const {hasProvider} = require('@extractus/oembed-extractor');
let provider;
// build up a list of URL variations to test against because the oembed
@ -95,6 +96,8 @@ class OEmbedService {
* @param {string} url
*/
async knownProvider(url) {
const {extract} = require('@extractus/oembed-extractor');
try {
return await extract(url);
} catch (err) {