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

Lazyloaded dependencies

- these dependencies do not need to be eagerly loaded so we can move
  them to the block of code where they are needed
This commit is contained in:
Daniel Lockyer 2024-10-09 14:21:11 +01:00 committed by Daniel Lockyer
parent 09b4aceb64
commit 5dedfbe82e
2 changed files with 5 additions and 5 deletions

View file

@ -1,8 +1,6 @@
const errors = require('@tryghost/errors');
const debug = require('@tryghost/debug')('minifier');
const tpl = require('@tryghost/tpl');
const csso = require('csso');
const terser = require('terser');
const glob = require('tiny-glob');
const path = require('path');
const fs = require('fs').promises;
@ -53,6 +51,7 @@ class Minifier {
}
async minifyCSS(contents) {
const csso = require('csso');
const result = await csso.minify(contents);
if (result && result.css) {
return result.css;
@ -61,6 +60,7 @@ class Minifier {
}
async minifyJS(contents) {
const terser = require('terser');
const result = await terser.minify(contents);
if (result && result.code) {
return result.code;
@ -111,8 +111,8 @@ class Minifier {
/**
* Minify files
*
* @param {Object} globs An object in the form of
*
* @param {Object} globs An object in the form of
* ```js
* {
* 'destination1.js': 'glob/*.js',

View file

@ -1,7 +1,6 @@
const ObjectID = require('bson-objectid').default;
const {ValidationError} = require('@tryghost/errors');
const MentionCreatedEvent = require('./MentionCreatedEvent');
const cheerio = require('cheerio');
module.exports = class Mention {
/** @type {Array} */
@ -47,6 +46,7 @@ module.exports = class Mention {
if (contentType.includes('text/html')) {
try {
const cheerio = require('cheerio');
const $ = cheerio.load(html);
const hasTargetUrl = $('a[href*="' + this.target.href + '"], img[src*="' + this.target.href + '"], video[src*="' + this.target.href + '"]').length > 0;
this.#verified = hasTargetUrl;