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 <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
legendecas 2023-11-10 00:21:10 +08:00
parent 996239b0be
commit 6b7197cb2b
No known key found for this signature in database
GPG Key ID: CB3C9EC2BC27057C
2 changed files with 6 additions and 8 deletions

View File

@ -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()) {
if (!require('internal/modules/esm/utils').isLoaderWorker()) {
const userLoaderPaths = getOptionValue('--experimental-loader');
if (userLoaderPaths.length > 0) {
if (!emittedLoaderFlagWarning) {

View File

@ -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) {