From bc3f7b540142a238f0b3714a87105b57fd5e900e Mon Sep 17 00:00:00 2001 From: legendecas Date: Fri, 10 Nov 2023 00:21:10 +0800 Subject: [PATCH] module: remove useCustomLoadersIfPresent flag The flag is always true and can be determined by isLoaderWorker solely. PR-URL: https://github.com/nodejs/node/pull/48655 Reviewed-By: Matteo Collina Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/modules/esm/loader.js | 10 ++++------ lib/internal/process/esm_loader.js | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 6044765c3709f5..d1ce6f1df1bceb 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -524,15 +524,13 @@ let emittedLoaderFlagWarning = false; * A loader instance is used as the main entry point for loading ES modules. Currently, this is a singleton; there is * only one used for loading the main module and everything in its dependency graph, though separate instances of this * class might be instantiated as part of bootstrap for other purposes. - * @param {boolean} useCustomLoadersIfPresent If the user has provided loaders via the --loader flag, use them. * @returns {ModuleLoader} */ -function createModuleLoader(useCustomLoadersIfPresent = true) { +function createModuleLoader() { let customizations = null; - if (useCustomLoadersIfPresent && - // Don't spawn a new worker if we're already in a worker thread created by instantiating CustomizedModuleLoader; - // doing so would cause an infinite loop. - !require('internal/modules/esm/utils').isLoaderWorker()) { + // Don't spawn a new worker if we're already in a worker thread created by instantiating CustomizedModuleLoader; + // doing so would cause an infinite loop. + if (!require('internal/modules/esm/utils').isLoaderWorker()) { const userLoaderPaths = getOptionValue('--experimental-loader'); if (userLoaderPaths.length > 0) { if (!emittedLoaderFlagWarning) { diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index 47c909c9e55435..0865d7ceef66b7 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -11,10 +11,10 @@ let esmLoader; module.exports = { get esmLoader() { - return esmLoader ??= createModuleLoader(true); + return esmLoader ??= createModuleLoader(); }, async loadESM(callback) { - esmLoader ??= createModuleLoader(true); + esmLoader ??= createModuleLoader(); try { const userImports = getOptionValue('--import'); if (userImports.length > 0) {