From a1393762f63a83e9e6f22538c6b7a9d1c996e915 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Mon, 8 Jan 2018 21:12:16 +0100 Subject: [PATCH] Lazily require modules in lib/common/index no issue - decreases chance of not-loaded modules or circular dependencies - e.g. the i18n implementation will use the settings-cache and the settings-cache uses lib/common/events --- core/server/lib/common/index.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/core/server/lib/common/index.js b/core/server/lib/common/index.js index 485abaa246..060a01bc57 100644 --- a/core/server/lib/common/index.js +++ b/core/server/lib/common/index.js @@ -1,4 +1,19 @@ -module.exports.i18n = require('./i18n'); -module.exports.events = require('./events'); -module.exports.errors = require('./errors'); -module.exports.logging = require('./logging'); +'use strict'; + +module.exports = { + get i18n() { + return require('./i18n'); + }, + + get events() { + return require('./events'); + }, + + get errors() { + return require('./errors'); + }, + + get logging() { + return require('./logging'); + } +};