mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Lazyloaded several required dependencies
- these dependencies can be pushed to be loaded later than upon boot, where boot time is critical - this commit makes boot about 4% faster
This commit is contained in:
parent
71d830e1c9
commit
09c59a6569
4 changed files with 9 additions and 7 deletions
|
@ -1,7 +1,9 @@
|
|||
const {SafeString} = require('../services/handlebars');
|
||||
const {html} = require('common-tags');
|
||||
|
||||
module.exports = function commentCount(options) {
|
||||
// Lazy require the dependency to keep boot fast
|
||||
const {html} = require('common-tags');
|
||||
|
||||
const empty = options.hash.empty === undefined ? '' : options.hash.empty;
|
||||
const singular = options.hash.singular === undefined ? 'comment' : options.hash.singular;
|
||||
const plural = options.hash.plural === undefined ? 'comments' : options.hash.plural;
|
||||
|
|
|
@ -12,15 +12,13 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|||
const argv = process.argv;
|
||||
const mode = argv[2];
|
||||
|
||||
const command = require('./core/cli/command');
|
||||
|
||||
// Switch between boot modes
|
||||
switch (mode) {
|
||||
case 'repl':
|
||||
case 'timetravel':
|
||||
case 'generate-data':
|
||||
case 'record-test':
|
||||
command.run(mode);
|
||||
require('./core/cli/command').run(mode);
|
||||
break;
|
||||
default:
|
||||
// New boot sequence
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const _ = require('lodash').runInContext();
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const htmlToText = require('html-to-text');
|
||||
|
||||
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
||||
|
||||
|
@ -41,7 +40,8 @@ class EmailContentGenerator {
|
|||
const compiled = _.template(content);
|
||||
const htmlContent = compiled(data);
|
||||
|
||||
// generate a plain-text version of the same email
|
||||
// lazyload the lib, and generate a plain-text version of the same email
|
||||
const htmlToText = require('html-to-text');
|
||||
const textContent = htmlToText.fromString(htmlContent);
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const logging = require('@tryghost/logging');
|
||||
const cheerio = require('cheerio');
|
||||
const _ = require('lodash');
|
||||
const charset = require('charset');
|
||||
const iconv = require('iconv-lite');
|
||||
|
@ -297,6 +296,9 @@ class OEmbedService {
|
|||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async fetchOembedData(url, html, cardType) {
|
||||
// Lazy require the library to keep boot quick
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
// check for <link rel="alternate" type="application/json+oembed"> element
|
||||
let oembedUrl;
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue