diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 7be15238aa366f..e6d30e2aa919f6 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -1,6 +1,7 @@ // This file creates the internal module & binding loaders used by built-in // modules. In contrast, user land modules are loaded using -// lib/module.js (CommonJS Modules) or lib/internal/loader/* (ES Modules). +// lib/internal/modules/cjs/loader.js (CommonJS Modules) or +// lib/internal/modules/esm/* (ES Modules). // // This file is compiled and run by node.cc before bootstrap/node.js // was called, therefore the loaders are bootstraped before we start to diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 9bcafd8e9b0861..8a87712613de7c 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -110,7 +110,7 @@ process.emitWarning( 'The ESM module loader is experimental.', 'ExperimentalWarning', undefined); - NativeModule.require('internal/process/modules').setup(); + NativeModule.require('internal/process/esm_loader').setup(); } @@ -170,8 +170,10 @@ preloadModules(); perf.markMilestone(NODE_PERFORMANCE_MILESTONE_PRELOAD_MODULE_LOAD_END); - const internalModule = NativeModule.require('internal/module'); - internalModule.addBuiltinLibsToObject(global); + const { + addBuiltinLibsToObject + } = NativeModule.require('internal/modules/cjs/helpers'); + addBuiltinLibsToObject(global); evalScript('[eval]'); } else if (process.argv[1] && process.argv[1] !== '-') { perf.markMilestone(NODE_PERFORMANCE_MILESTONE_MODULE_LOAD_START); @@ -179,13 +181,13 @@ const path = NativeModule.require('path'); process.argv[1] = path.resolve(process.argv[1]); - const Module = NativeModule.require('module'); + const CJSModule = NativeModule.require('internal/modules/cjs/loader'); // check if user passed `-c` or `--check` arguments to Node. if (process._syntax_check_only != null) { const fs = NativeModule.require('fs'); // read the source - const filename = Module._resolveFilename(process.argv[1]); + const filename = CJSModule._resolveFilename(process.argv[1]); const source = fs.readFileSync(filename, 'utf-8'); checkScriptSyntax(source, filename); process.exit(0); @@ -196,7 +198,7 @@ preloadModules(); perf.markMilestone( NODE_PERFORMANCE_MILESTONE_PRELOAD_MODULE_LOAD_END); - Module.runMain(); + CJSModule.runMain(); } else { perf.markMilestone(NODE_PERFORMANCE_MILESTONE_MODULE_LOAD_START); perf.markMilestone(NODE_PERFORMANCE_MILESTONE_MODULE_LOAD_END); @@ -321,7 +323,7 @@ function setupGlobalConsole() { const originalConsole = global.console; - const Module = NativeModule.require('module'); + const CJSModule = NativeModule.require('internal/modules/cjs/loader'); // Setup Node.js global.console const wrappedConsole = NativeModule.require('console'); Object.defineProperty(global, 'console', { @@ -331,22 +333,23 @@ return wrappedConsole; } }); - setupInspector(originalConsole, wrappedConsole, Module); + setupInspector(originalConsole, wrappedConsole, CJSModule); } - function setupInspector(originalConsole, wrappedConsole, Module) { + function setupInspector(originalConsole, wrappedConsole, CJSModule) { if (!process.config.variables.v8_enable_inspector) { return; } const { addCommandLineAPI, consoleCall } = process.binding('inspector'); // Setup inspector command line API - const { makeRequireFunction } = NativeModule.require('internal/module'); + const { makeRequireFunction } = + NativeModule.require('internal/modules/cjs/helpers'); const path = NativeModule.require('path'); const cwd = tryGetCwd(path); - const consoleAPIModule = new Module(''); + const consoleAPIModule = new CJSModule(''); consoleAPIModule.paths = - Module._nodeModulePaths(cwd).concat(Module.globalPaths); + CJSModule._nodeModulePaths(cwd).concat(CJSModule.globalPaths); addCommandLineAPI('require', makeRequireFunction(consoleAPIModule)); const config = {}; for (const key of Object.keys(wrappedConsole)) { @@ -461,13 +464,13 @@ } function evalScript(name) { - const Module = NativeModule.require('module'); + const CJSModule = NativeModule.require('internal/modules/cjs/loader'); const path = NativeModule.require('path'); const cwd = tryGetCwd(path); - const module = new Module(name); + const module = new CJSModule(name); module.filename = path.join(cwd, name); - module.paths = Module._nodeModulePaths(cwd); + module.paths = CJSModule._nodeModulePaths(cwd); const body = wrapForBreakOnFirstLine(process._eval); const script = `global.__filename = ${JSON.stringify(name)};\n` + 'global.exports = exports;\n' + @@ -486,21 +489,26 @@ // Load preload modules function preloadModules() { if (process._preload_modules) { - NativeModule.require('module')._preloadModules(process._preload_modules); + const { + _preloadModules + } = NativeModule.require('internal/modules/cjs/loader'); + _preloadModules(process._preload_modules); } } function checkScriptSyntax(source, filename) { - const Module = NativeModule.require('module'); + const CJSModule = NativeModule.require('internal/modules/cjs/loader'); const vm = NativeModule.require('vm'); - const internalModule = NativeModule.require('internal/module'); + const { + stripShebang, stripBOM + } = NativeModule.require('internal/modules/cjs/helpers'); // remove Shebang - source = internalModule.stripShebang(source); + source = stripShebang(source); // remove BOM - source = internalModule.stripBOM(source); + source = stripBOM(source); // wrap it - source = Module.wrap(source); + source = CJSModule.wrap(source); // compile the script, this will throw if it fails new vm.Script(source, { displayErrors: true, filename }); } diff --git a/lib/internal/module.js b/lib/internal/modules/cjs/helpers.js similarity index 100% rename from lib/internal/module.js rename to lib/internal/modules/cjs/helpers.js diff --git a/lib/module.js b/lib/internal/modules/cjs/loader.js similarity index 97% rename from lib/module.js rename to lib/internal/modules/cjs/loader.js index 0840b9d946f8a4..39333f049f6c1a 100644 --- a/lib/module.js +++ b/lib/internal/modules/cjs/loader.js @@ -34,7 +34,12 @@ const { internalModuleReadFile, internalModuleStat } = process.binding('fs'); -const internalModule = require('internal/module'); +const { + makeRequireFunction, + requireDepth, + stripBOM, + stripShebang +} = require('internal/modules/cjs/helpers'); const preserveSymlinks = !!process.binding('config').preserveSymlinks; const experimentalModules = !!process.binding('config').experimentalModules; @@ -43,9 +48,9 @@ const errors = require('internal/errors'); module.exports = Module; // these are below module.exports for the circular reference -const internalESModule = require('internal/process/modules'); -const ModuleJob = require('internal/loader/ModuleJob'); -const createDynamicModule = require('internal/loader/CreateDynamicModule'); +const asyncESM = require('internal/process/esm_loader'); +const ModuleJob = require('internal/modules/esm/ModuleJob'); +const createDynamicModule = require('internal/modules/esm/CreateDynamicModule'); function stat(filename) { filename = path.toNamespacedPath(filename); @@ -456,7 +461,7 @@ Module._load = function(request, parent, isMain) { } if (experimentalModules && isMain) { - internalESModule.loaderPromise.then((loader) => { + asyncESM.loaderPromise.then((loader) => { return loader.import(getURLFromFilePath(request).pathname); }) .catch((e) => { @@ -562,7 +567,7 @@ Module.prototype.load = function(filename) { this.loaded = true; if (experimentalModules) { - const ESMLoader = internalESModule.ESMLoader; + const ESMLoader = asyncESM.ESMLoader; const url = getURLFromFilePath(filename); const urlString = `${url}`; const exports = this.exports; @@ -605,7 +610,7 @@ var resolvedArgv; // Returns exception, if any. Module.prototype._compile = function(content, filename) { - content = internalModule.stripShebang(content); + content = stripShebang(content); // create wrapper function var wrapper = Module.wrap(content); @@ -638,8 +643,8 @@ Module.prototype._compile = function(content, filename) { } } var dirname = path.dirname(filename); - var require = internalModule.makeRequireFunction(this); - var depth = internalModule.requireDepth; + var require = makeRequireFunction(this); + var depth = requireDepth; if (depth === 0) stat.cache = new Map(); var result; if (inspectorWrapper) { @@ -657,7 +662,7 @@ Module.prototype._compile = function(content, filename) { // Native extension for .js Module._extensions['.js'] = function(module, filename) { var content = fs.readFileSync(filename, 'utf8'); - module._compile(internalModule.stripBOM(content), filename); + module._compile(stripBOM(content), filename); }; @@ -665,7 +670,7 @@ Module._extensions['.js'] = function(module, filename) { Module._extensions['.json'] = function(module, filename) { var content = fs.readFileSync(filename, 'utf8'); try { - module.exports = JSON.parse(internalModule.stripBOM(content)); + module.exports = JSON.parse(stripBOM(content)); } catch (err) { err.message = filename + ': ' + err.message; throw err; diff --git a/lib/internal/loader/CreateDynamicModule.js b/lib/internal/modules/esm/CreateDynamicModule.js similarity index 100% rename from lib/internal/loader/CreateDynamicModule.js rename to lib/internal/modules/esm/CreateDynamicModule.js diff --git a/lib/internal/loader/DefaultResolve.js b/lib/internal/modules/esm/DefaultResolve.js similarity index 97% rename from lib/internal/loader/DefaultResolve.js rename to lib/internal/modules/esm/DefaultResolve.js index fe9ccfd5db55ed..8d9240dedbd89a 100644 --- a/lib/internal/loader/DefaultResolve.js +++ b/lib/internal/modules/esm/DefaultResolve.js @@ -1,7 +1,7 @@ 'use strict'; const { URL } = require('url'); -const CJSmodule = require('module'); +const CJSmodule = require('internal/modules/cjs/loader'); const internalFS = require('internal/fs'); const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); const { extname } = require('path'); diff --git a/lib/internal/loader/Loader.js b/lib/internal/modules/esm/Loader.js similarity index 92% rename from lib/internal/loader/Loader.js rename to lib/internal/modules/esm/Loader.js index f0edbbf921f40f..170fa23ec798ff 100644 --- a/lib/internal/loader/Loader.js +++ b/lib/internal/modules/esm/Loader.js @@ -1,11 +1,11 @@ 'use strict'; const errors = require('internal/errors'); -const ModuleMap = require('internal/loader/ModuleMap'); -const ModuleJob = require('internal/loader/ModuleJob'); -const defaultResolve = require('internal/loader/DefaultResolve'); -const createDynamicModule = require('internal/loader/CreateDynamicModule'); -const translators = require('internal/loader/Translators'); +const ModuleMap = require('internal/modules/esm/ModuleMap'); +const ModuleJob = require('internal/modules/esm/ModuleJob'); +const defaultResolve = require('internal/modules/esm/DefaultResolve'); +const createDynamicModule = require('internal/modules/esm/CreateDynamicModule'); +const translators = require('internal/modules/esm/Translators'); const FunctionBind = Function.call.bind(Function.prototype.bind); diff --git a/lib/internal/loader/ModuleJob.js b/lib/internal/modules/esm/ModuleJob.js similarity index 100% rename from lib/internal/loader/ModuleJob.js rename to lib/internal/modules/esm/ModuleJob.js diff --git a/lib/internal/loader/ModuleMap.js b/lib/internal/modules/esm/ModuleMap.js similarity index 93% rename from lib/internal/loader/ModuleMap.js rename to lib/internal/modules/esm/ModuleMap.js index aa238afbaedc05..7f5ee8bf9e7762 100644 --- a/lib/internal/loader/ModuleMap.js +++ b/lib/internal/modules/esm/ModuleMap.js @@ -1,6 +1,6 @@ 'use strict'; -const ModuleJob = require('internal/loader/ModuleJob'); +const ModuleJob = require('internal/modules/esm/ModuleJob'); const { SafeMap } = require('internal/safe_globals'); const debug = require('util').debuglog('esm'); const errors = require('internal/errors'); diff --git a/lib/internal/loader/ModuleWrap.js b/lib/internal/modules/esm/ModuleWrap.js similarity index 100% rename from lib/internal/loader/ModuleWrap.js rename to lib/internal/modules/esm/ModuleWrap.js diff --git a/lib/internal/loader/Translators.js b/lib/internal/modules/esm/Translators.js similarity index 90% rename from lib/internal/loader/Translators.js rename to lib/internal/modules/esm/Translators.js index 8796b4ddfd00e5..2928115be515e0 100644 --- a/lib/internal/loader/Translators.js +++ b/lib/internal/modules/esm/Translators.js @@ -2,10 +2,13 @@ const { NativeModule, internalBinding } = require('internal/bootstrap/loaders'); const { ModuleWrap } = internalBinding('module_wrap'); -const internalCJSModule = require('internal/module'); -const CJSModule = require('module'); +const { + stripShebang, + stripBOM +} = require('internal/modules/cjs/helpers'); +const CJSModule = require('internal/modules/cjs/loader'); const internalURLModule = require('internal/url'); -const createDynamicModule = require('internal/loader/CreateDynamicModule'); +const createDynamicModule = require('internal/modules/esm/CreateDynamicModule'); const fs = require('fs'); const { _makeLong } = require('path'); const { SafeMap } = require('internal/safe_globals'); @@ -24,7 +27,7 @@ translators.set('esm', async (url) => { const source = `${await readFileAsync(new URL(url))}`; debug(`Translating StandardModule ${url}`); return { - module: new ModuleWrap(internalCJSModule.stripShebang(source), url), + module: new ModuleWrap(stripShebang(source), url), reflect: undefined }; }); @@ -82,7 +85,7 @@ translators.set('json', async (url) => { const pathname = internalURLModule.getPathFromURL(new URL(url)); const content = readFileSync(pathname, 'utf8'); try { - const exports = JsonParse(internalCJSModule.stripBOM(content)); + const exports = JsonParse(stripBOM(content)); reflect.exports.default.set(exports); } catch (err) { err.message = pathname + ': ' + err.message; diff --git a/lib/internal/process/modules.js b/lib/internal/process/esm_loader.js similarity index 95% rename from lib/internal/process/modules.js rename to lib/internal/process/esm_loader.js index 2cbc65a5dabd3d..ca2ce57feb54d8 100644 --- a/lib/internal/process/modules.js +++ b/lib/internal/process/esm_loader.js @@ -6,7 +6,7 @@ const { } = internalBinding('module_wrap'); const { getURLFromFilePath } = require('internal/url'); -const Loader = require('internal/loader/Loader'); +const Loader = require('internal/modules/esm/Loader'); const path = require('path'); const { URL } = require('url'); diff --git a/lib/repl.js b/lib/repl.js index 5779e849f06017..83d6b59a721061 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -42,7 +42,11 @@ 'use strict'; -const internalModule = require('internal/module'); +const { + builtinLibs, + makeRequireFunction, + addBuiltinLibsToObject +} = require('internal/modules/cjs/helpers'); const internalUtil = require('internal/util'); const { isTypedArray } = require('internal/util/types'); const util = require('util'); @@ -54,7 +58,7 @@ const path = require('path'); const fs = require('fs'); const { Interface } = require('readline'); const { Console } = require('console'); -const Module = require('module'); +const CJSModule = require('internal/modules/cjs/loader'); const domain = require('domain'); const debug = util.debuglog('repl'); const errors = require('internal/errors'); @@ -90,7 +94,7 @@ try { } // Hack for repl require to work properly with node_modules folders -module.paths = Module._nodeModulePaths(module.filename); +module.paths = CJSModule._nodeModulePaths(module.filename); // If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. @@ -103,7 +107,7 @@ function hasOwnProperty(obj, prop) { // This is the default "writer" value if none is passed in the REPL options. exports.writer = util.inspect; -exports._builtinLibs = internalModule.builtinLibs; +exports._builtinLibs = builtinLibs; function REPLServer(prompt, stream, @@ -673,14 +677,15 @@ REPLServer.prototype.createContext = function() { } } - var module = new Module(''); - module.paths = Module._resolveLookupPaths('', parentModule, true) || []; + var module = new CJSModule(''); + module.paths = + CJSModule._resolveLookupPaths('', parentModule, true) || []; - var require = internalModule.makeRequireFunction(module); + var require = makeRequireFunction(module); context.module = module; context.require = require; - internalModule.addBuiltinLibsToObject(context); + addBuiltinLibsToObject(context); return context; }; @@ -889,7 +894,7 @@ function complete(line, callback) { } else if (/^\.\.?\//.test(completeOn)) { paths = [process.cwd()]; } else { - paths = module.paths.concat(Module.globalPaths); + paths = module.paths.concat(CJSModule.globalPaths); } for (i = 0; i < paths.length; i++) { diff --git a/node.gyp b/node.gyp index 9e6a286a0bf53b..01e7cc3a5e1bfd 100644 --- a/node.gyp +++ b/node.gyp @@ -105,18 +105,19 @@ 'lib/internal/http.js', 'lib/internal/inspector_async_hook.js', 'lib/internal/linkedlist.js', - 'lib/internal/loader/Loader.js', - 'lib/internal/loader/CreateDynamicModule.js', - 'lib/internal/loader/DefaultResolve.js', - 'lib/internal/loader/ModuleJob.js', - 'lib/internal/loader/ModuleMap.js', - 'lib/internal/loader/ModuleWrap.js', - 'lib/internal/loader/Translators.js', + 'lib/internal/modules/cjs/helpers.js', + 'lib/internal/modules/cjs/loader.js', + 'lib/internal/modules/esm/Loader.js', + 'lib/internal/modules/esm/CreateDynamicModule.js', + 'lib/internal/modules/esm/DefaultResolve.js', + 'lib/internal/modules/esm/ModuleJob.js', + 'lib/internal/modules/esm/ModuleMap.js', + 'lib/internal/modules/esm/ModuleWrap.js', + 'lib/internal/modules/esm/Translators.js', 'lib/internal/safe_globals.js', 'lib/internal/net.js', - 'lib/internal/module.js', 'lib/internal/os.js', - 'lib/internal/process/modules.js', + 'lib/internal/process/esm_loader.js', 'lib/internal/process/next_tick.js', 'lib/internal/process/promises.js', 'lib/internal/process/stdio.js', diff --git a/test/es-module/test-esm-loader-modulemap.js b/test/es-module/test-esm-loader-modulemap.js index 1c1623b680e7bd..e9faa6d9f122f4 100644 --- a/test/es-module/test-esm-loader-modulemap.js +++ b/test/es-module/test-esm-loader-modulemap.js @@ -7,10 +7,10 @@ const common = require('../common'); const { URL } = require('url'); -const Loader = require('internal/loader/Loader'); -const ModuleMap = require('internal/loader/ModuleMap'); -const ModuleJob = require('internal/loader/ModuleJob'); -const createDynamicModule = require('internal/loader/CreateDynamicModule'); +const Loader = require('internal/modules/esm/Loader'); +const ModuleMap = require('internal/modules/esm/ModuleMap'); +const ModuleJob = require('internal/modules/esm/ModuleJob'); +const createDynamicModule = require('internal/modules/esm/CreateDynamicModule'); const stubModuleUrl = new URL('file://tmp/test'); const stubModule = createDynamicModule(['default'], stubModuleUrl); diff --git a/test/es-module/test-esm-loader-search.js b/test/es-module/test-esm-loader-search.js index 4eb6b9fd4b3889..5a1f5a562a0d3e 100644 --- a/test/es-module/test-esm-loader-search.js +++ b/test/es-module/test-esm-loader-search.js @@ -5,7 +5,7 @@ const common = require('../common'); -const { search } = require('internal/loader/DefaultResolve'); +const { search } = require('internal/modules/esm/DefaultResolve'); const errors = require('internal/errors'); common.expectsError( diff --git a/test/fixtures/module-require-depth/one.js b/test/fixtures/module-require-depth/one.js index 5927908b7540ab..02b451465bb76c 100644 --- a/test/fixtures/module-require-depth/one.js +++ b/test/fixtures/module-require-depth/one.js @@ -1,9 +1,11 @@ // Flags: --expose_internals 'use strict'; const assert = require('assert'); -const internalModule = require('internal/module'); +const { + requireDepth +} = require('internal/modules/cjs/helpers'); -exports.requireDepth = internalModule.requireDepth; -assert.strictEqual(internalModule.requireDepth, 1); +exports.requireDepth = requireDepth; +assert.strictEqual(requireDepth, 1); assert.deepStrictEqual(require('./two'), { requireDepth: 2 }); -assert.strictEqual(internalModule.requireDepth, 1); +assert.strictEqual(requireDepth, 1); diff --git a/test/fixtures/module-require-depth/two.js b/test/fixtures/module-require-depth/two.js index aea49947d1152d..5c94c4c89aa9ef 100644 --- a/test/fixtures/module-require-depth/two.js +++ b/test/fixtures/module-require-depth/two.js @@ -1,9 +1,11 @@ // Flags: --expose_internals 'use strict'; const assert = require('assert'); -const internalModule = require('internal/module'); +const { + requireDepth +} = require('internal/modules/cjs/helpers'); -exports.requireDepth = internalModule.requireDepth; -assert.strictEqual(internalModule.requireDepth, 2); +exports.requireDepth = requireDepth; +assert.strictEqual(requireDepth, 2); assert.deepStrictEqual(require('./one'), { requireDepth: 1 }); -assert.strictEqual(internalModule.requireDepth, 2); +assert.strictEqual(requireDepth, 2); diff --git a/test/message/core_line_numbers.out b/test/message/core_line_numbers.out index 5658a5a59ecbcd..b50e1678f49fb7 100644 --- a/test/message/core_line_numbers.out +++ b/test/message/core_line_numbers.out @@ -6,10 +6,10 @@ RangeError: Invalid input at error (punycode.js:42:*) at Object.decode (punycode.js:*:*) at Object. (*test*message*core_line_numbers.js:*:*) - at Module._compile (module.js:*:*) - at Object.Module._extensions..js (module.js:*:*) - at Module.load (module.js:*:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) + at Module.load (internal/modules/cjs/loader.js:*:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) diff --git a/test/message/error_exit.out b/test/message/error_exit.out index f26287d57f61c0..fd580c389af0bd 100644 --- a/test/message/error_exit.out +++ b/test/message/error_exit.out @@ -5,11 +5,11 @@ assert.js:* AssertionError [ERR_ASSERTION]: 1 === 2 at Object. (*test*message*error_exit.js:*:*) - at Module._compile (module.js:*:*) - at Object.Module._extensions..js (module.js:*:*) - at Module.load (module.js:*:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) + at Module.load (internal/modules/cjs/loader.js:*:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/esm_display_syntax_error.out b/test/message/esm_display_syntax_error.out index a47a7e1339273f..73c9495824038e 100644 --- a/test/message/esm_display_syntax_error.out +++ b/test/message/esm_display_syntax_error.out @@ -3,5 +3,5 @@ file:///*/test/message/esm_display_syntax_error.mjs:3 await async () => 0; ^^^^^ SyntaxError: Unexpected reserved word - at translators.set (internal/loader/Translators.js:*:*) + at translators.set (internal/modules/esm/Translators.js:*:*) at diff --git a/test/message/esm_display_syntax_error_import.out b/test/message/esm_display_syntax_error_import.out index 1fb7fdc34a7de4..e257f0eb7a94e5 100644 --- a/test/message/esm_display_syntax_error_import.out +++ b/test/message/esm_display_syntax_error_import.out @@ -3,5 +3,5 @@ file:///*/test/message/esm_display_syntax_error_import.mjs:6 notfound ^^^^^^^^ SyntaxError: The requested module does not provide an export named 'notfound' - at ModuleJob._instantiate (internal/loader/ModuleJob.js:*:*) + at ModuleJob._instantiate (internal/modules/esm/ModuleJob.js:*:*) at diff --git a/test/message/esm_display_syntax_error_import_module.out b/test/message/esm_display_syntax_error_import_module.out index 77fd63891f1ea0..c6286a2a987282 100644 --- a/test/message/esm_display_syntax_error_import_module.out +++ b/test/message/esm_display_syntax_error_import_module.out @@ -3,5 +3,5 @@ file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1 import { foo, notfound } from './module-named-exports'; ^^^^^^^^ SyntaxError: The requested module does not provide an export named 'notfound' - at ModuleJob._instantiate (internal/loader/ModuleJob.js:*:*) + at ModuleJob._instantiate (internal/modules/esm/ModuleJob.js:*:*) at diff --git a/test/message/esm_display_syntax_error_module.out b/test/message/esm_display_syntax_error_module.out index 23da9f350e5efe..122e352102ad0f 100644 --- a/test/message/esm_display_syntax_error_module.out +++ b/test/message/esm_display_syntax_error_module.out @@ -3,5 +3,5 @@ file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2 await async () => 0; ^^^^^ SyntaxError: Unexpected reserved word - at translators.set (internal/loader/Translators.js:*:*) + at translators.set (internal/modules/esm/Translators.js:*:*) at diff --git a/test/message/eval_messages.out b/test/message/eval_messages.out index 84772ffa48a14f..d01dfe547cbd73 100644 --- a/test/message/eval_messages.out +++ b/test/message/eval_messages.out @@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement at createScript (vm.js:*:*) at Object.runInThisContext (vm.js:*:*) at Object. ([eval]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) @@ -22,7 +22,7 @@ Error: hello at Script.runInThisContext (vm.js:*:*) at Object.runInThisContext (vm.js:*:*) at Object. ([eval]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) @@ -36,7 +36,7 @@ Error: hello at Script.runInThisContext (vm.js:*:*) at Object.runInThisContext (vm.js:*:*) at Object. ([eval]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) @@ -50,7 +50,7 @@ ReferenceError: y is not defined at Script.runInThisContext (vm.js:*:*) at Object.runInThisContext (vm.js:*:*) at Object. ([eval]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/events_unhandled_error_common_trace.out b/test/message/events_unhandled_error_common_trace.out index 003446edaa5e17..f6b74e9991306b 100644 --- a/test/message/events_unhandled_error_common_trace.out +++ b/test/message/events_unhandled_error_common_trace.out @@ -6,17 +6,17 @@ Error: foo:bar at bar (*events_unhandled_error_common_trace.js:*:*) at foo (*events_unhandled_error_common_trace.js:*:*) at Object. (*events_unhandled_error_common_trace.js:*:*) - at Module._compile (module.js:*:*) - at Object.Module._extensions..js (module.js:*:*) - at Module.load (module.js:*:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) + at Module.load (internal/modules/cjs/loader.js:*:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) Emitted 'error' event at: at quux (*events_unhandled_error_common_trace.js:*:*) at Object. (*events_unhandled_error_common_trace.js:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) [... lines matching original stack trace ...] at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/events_unhandled_error_nexttick.out b/test/message/events_unhandled_error_nexttick.out index 5912f9fd387b4c..e00580ce93cf45 100644 --- a/test/message/events_unhandled_error_nexttick.out +++ b/test/message/events_unhandled_error_nexttick.out @@ -4,17 +4,17 @@ events.js:* Error at Object. (*events_unhandled_error_nexttick.js:*:*) - at Module._compile (module.js:*:*) - at Object.Module._extensions..js (module.js:*:*) - at Module.load (module.js:*:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) + at Module.load (internal/modules/cjs/loader.js:*:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) Emitted 'error' event at: at process.nextTick (*events_unhandled_error_nexttick.js:*:*) at process._tickCallback (internal/process/next_tick.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/events_unhandled_error_sameline.out b/test/message/events_unhandled_error_sameline.out index dcbb45afbd4240..55841cdbc345d7 100644 --- a/test/message/events_unhandled_error_sameline.out +++ b/test/message/events_unhandled_error_sameline.out @@ -4,16 +4,16 @@ events.js:* Error at Object. (*events_unhandled_error_sameline.js:*:*) - at Module._compile (module.js:*:*) - at Object.Module._extensions..js (module.js:*:*) - at Module.load (module.js:*:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*) + at Module.load (internal/modules/cjs/loader.js:*:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) Emitted 'error' event at: at Object. (*events_unhandled_error_sameline.js:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) [... lines matching original stack trace ...] at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/nexttick_throw.out b/test/message/nexttick_throw.out index 798b208d7d9049..16e41f6343baec 100644 --- a/test/message/nexttick_throw.out +++ b/test/message/nexttick_throw.out @@ -5,6 +5,6 @@ ReferenceError: undefined_reference_error_maker is not defined at *test*message*nexttick_throw.js:*:* at process._tickCallback (internal/process/next_tick.js:*:*) - at Function.Module.runMain (module.js:*:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) at startup (internal/bootstrap/node.js:*:*) at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*) diff --git a/test/message/stdin_messages.out b/test/message/stdin_messages.out index c6c37a5be4f397..d4498b452aa6ba 100644 --- a/test/message/stdin_messages.out +++ b/test/message/stdin_messages.out @@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement at createScript (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at Socket. (internal/bootstrap/node.js:*:*) at Socket.emit (events.js:*:*) @@ -24,7 +24,7 @@ Error: hello at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at Socket. (internal/bootstrap/node.js:*:*) at Socket.emit (events.js:*:*) @@ -39,7 +39,7 @@ Error: hello at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at Socket. (internal/bootstrap/node.js:*:*) at Socket.emit (events.js:*:*) @@ -55,7 +55,7 @@ ReferenceError: y is not defined at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. ([stdin]-wrapper:*:*) - at Module._compile (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*:*) at evalScript (internal/bootstrap/node.js:*:*) at Socket. (internal/bootstrap/node.js:*:*) at Socket.emit (events.js:*:*) diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out index ff517cc981a255..6b5fedfa993701 100644 --- a/test/message/undefined_reference_in_new_context.out +++ b/test/message/undefined_reference_in_new_context.out @@ -9,8 +9,8 @@ ReferenceError: foo is not defined at Script.runInNewContext (vm.js:*) at Object.runInNewContext (vm.js:*) at Object. (*test*message*undefined_reference_in_new_context.js:*) - at Module._compile (module.js:*) - at *..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at *..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*:*) diff --git a/test/message/vm_display_runtime_error.out b/test/message/vm_display_runtime_error.out index 056ea79f8d39b4..bc95b2a7b092f5 100644 --- a/test/message/vm_display_runtime_error.out +++ b/test/message/vm_display_runtime_error.out @@ -8,12 +8,12 @@ Error: boo! at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_display_runtime_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) test.vm:1 throw new Error("spooky!") ^ @@ -23,9 +23,9 @@ Error: spooky! at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_display_runtime_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) diff --git a/test/message/vm_display_syntax_error.out b/test/message/vm_display_syntax_error.out index f3b9953307db19..f0692723e81257 100644 --- a/test/message/vm_display_syntax_error.out +++ b/test/message/vm_display_syntax_error.out @@ -7,12 +7,12 @@ SyntaxError: Unexpected number at createScript (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_display_syntax_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) test.vm:1 var 5; ^ @@ -21,9 +21,9 @@ SyntaxError: Unexpected number at createScript (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_display_syntax_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) diff --git a/test/message/vm_dont_display_runtime_error.out b/test/message/vm_dont_display_runtime_error.out index a7e06d49f85a7c..532cfbf4dd8125 100644 --- a/test/message/vm_dont_display_runtime_error.out +++ b/test/message/vm_dont_display_runtime_error.out @@ -9,9 +9,9 @@ Error: boo! at Script.runInThisContext (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_dont_display_runtime_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) diff --git a/test/message/vm_dont_display_syntax_error.out b/test/message/vm_dont_display_syntax_error.out index 5c74c25dd8aa3b..f27cb1a0859d8c 100644 --- a/test/message/vm_dont_display_syntax_error.out +++ b/test/message/vm_dont_display_syntax_error.out @@ -9,9 +9,9 @@ SyntaxError: Unexpected number at createScript (vm.js:*) at Object.runInThisContext (vm.js:*) at Object. (*test*message*vm_dont_display_syntax_error.js:*) - at Module._compile (module.js:*) - at Object.Module._extensions..js (module.js:*) - at Module.load (module.js:*) - at tryModuleLoad (module.js:*:*) - at Function.Module._load (module.js:*) - at Function.Module.runMain (module.js:*) + at Module._compile (internal/modules/cjs/loader.js:*) + at Object.Module._extensions..js (internal/modules/cjs/loader.js:*) + at Module.load (internal/modules/cjs/loader.js:*) + at tryModuleLoad (internal/modules/cjs/loader.js:*:*) + at Function.Module._load (internal/modules/cjs/loader.js:*) + at Function.Module.runMain (internal/modules/cjs/loader.js:*) diff --git a/test/parallel/test-internal-module-map-asserts.js b/test/parallel/test-internal-module-map-asserts.js index 1160c910421b80..330f04cfd96800 100644 --- a/test/parallel/test-internal-module-map-asserts.js +++ b/test/parallel/test-internal-module-map-asserts.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); -const ModuleMap = require('internal/loader/ModuleMap'); +const ModuleMap = require('internal/modules/esm/ModuleMap'); // ModuleMap.get, ModuleMap.has and ModuleMap.set should only accept string // values as url argument. diff --git a/test/parallel/test-internal-module-wrap.js b/test/parallel/test-internal-module-wrap.js index 634d1ebc6f678e..050cc18a4dbee6 100644 --- a/test/parallel/test-internal-module-wrap.js +++ b/test/parallel/test-internal-module-wrap.js @@ -6,7 +6,7 @@ const common = require('../common'); common.crashOnUnhandledRejection(); const assert = require('assert'); -const ModuleWrap = require('internal/loader/ModuleWrap'); +const ModuleWrap = require('internal/modules/esm/ModuleWrap'); const { getPromiseDetails, isPromise } = process.binding('util'); const setTimeoutAsync = require('util').promisify(setTimeout); diff --git a/test/parallel/test-internal-modules-strip-shebang.js b/test/parallel/test-internal-modules-strip-shebang.js index 93be3d41981f50..6c23848a969231 100644 --- a/test/parallel/test-internal-modules-strip-shebang.js +++ b/test/parallel/test-internal-modules-strip-shebang.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); -const stripShebang = require('internal/module').stripShebang; +const stripShebang = require('internal/modules/cjs/helpers').stripShebang; [ ['', ''], diff --git a/test/parallel/test-module-cjs-helpers.js b/test/parallel/test-module-cjs-helpers.js index 5407464d57942d..1ed9746198a606 100644 --- a/test/parallel/test-module-cjs-helpers.js +++ b/test/parallel/test-module-cjs-helpers.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); -const { builtinLibs } = require('internal/module'); +const { builtinLibs } = require('internal/modules/cjs/helpers'); const hasInspector = process.config.variables.v8_enable_inspector === 1; diff --git a/test/parallel/test-module-require-depth.js b/test/parallel/test-module-require-depth.js index 151934917cd678..0a3fc2826c71f4 100644 --- a/test/parallel/test-module-require-depth.js +++ b/test/parallel/test-module-require-depth.js @@ -3,12 +3,14 @@ require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); -const internalModule = require('internal/module'); +const { + requireDepth +} = require('internal/modules/cjs/helpers'); // Module one loads two too so the expected depth for two is, well, two. -assert.strictEqual(internalModule.requireDepth, 0); +assert.strictEqual(requireDepth, 0); const one = require(fixtures.path('module-require-depth', 'one')); const two = require(fixtures.path('module-require-depth', 'two')); assert.deepStrictEqual(one, { requireDepth: 1 }); assert.deepStrictEqual(two, { requireDepth: 2 }); -assert.strictEqual(internalModule.requireDepth, 0); +assert.strictEqual(requireDepth, 0);