diff --git a/doc/api/cli.md b/doc/api/cli.md index 2c60e9c5b1dc3e..995ae72a931aba 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -192,7 +192,7 @@ Specify the `module` of a custom [experimental ECMAScript Module loader][]. added: v8.5.0 --> -Enable experimental ES module support and caching modules. +Enable latest experimental modules features (deprecated). ### `--experimental-policy` -Used with `--experimental-modules`, this configures Node.js to interpret string -input as CommonJS or as an ES module. String input is input via `--eval`, -`--print`, or `STDIN`. +This configures Node.js to interpret string input as CommonJS or as an ES +module. String input is input via `--eval`, `--print`, or `STDIN`. Valid values are `"commonjs"` and `"module"`. The default is `"commonjs"`. diff --git a/doc/api/esm.md b/doc/api/esm.md index 3de66a822def27..3f6eb9772b0a88 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -27,12 +27,9 @@ specifier resolution, and default behavior. -The `--experimental-modules` flag can be used to enable support for -ECMAScript modules (ES modules). - -Once enabled, Node.js will treat the following as ES modules when passed to -`node` as the initial input, or when referenced by `import` statements within -ES module code: +Experimental support for ECMAScript modules is enabled by default. +Node.js will treat the following as ES modules when passed to `node` as the +initial input, or when referenced by `import` statements within ES module code: * Files ending in `.mjs`. @@ -78,7 +75,7 @@ until the root of the volume is reached. ```sh # In same folder as above package.json -node --experimental-modules my-app.js # Runs as ES module +node my-app.js # Runs as ES module ``` If the nearest parent `package.json` lacks a `"type"` field, or contains @@ -113,9 +110,8 @@ project’s `node_modules` folder contains its own `package.json` file, so each project’s dependencies have their own package scopes. A `package.json` lacking a `"type"` field is treated as if it contained `"type": "commonjs"`. -The package scope applies not only to initial entry points (`node ---experimental-modules my-app.js`) but also to files referenced by `import` -statements and `import()` expressions. +The package scope applies not only to initial entry points (`node my-app.js`) +but also to files referenced by `import` statements and `import()` expressions. ```js // my-app.js, in an ES module package scope because there is a package.json @@ -168,11 +164,9 @@ piped to `node` via `STDIN`, will be treated as ES modules when the `--input-type=module` flag is set. ```sh -node --experimental-modules --input-type=module --eval \ - "import { sep } from 'path'; console.log(sep);" +node --input-type=module --eval "import { sep } from 'path'; console.log(sep);" -echo "import { sep } from 'path'; console.log(sep);" | \ - node --experimental-modules --input-type=module +echo "import { sep } from 'path'; console.log(sep);" | node --input-type=module ``` For completeness there is also `--input-type=commonjs`, for explicitly running @@ -1004,8 +998,8 @@ The `--experimental-json-modules` flag is needed for the module to work. ```bash -node --experimental-modules index.mjs # fails -node --experimental-modules --experimental-json-modules index.mjs # works +node index.mjs # fails +node --experimental-json-modules index.mjs # works ``` ## Experimental Wasm Modules @@ -1027,7 +1021,7 @@ console.log(M); executed under: ```bash -node --experimental-modules --experimental-wasm-modules index.mjs +node --experimental-wasm-modules index.mjs ``` would provide the exports interface for the instantiation of `module.wasm`. @@ -1173,7 +1167,7 @@ export async function getSource(url, context, defaultGetSource) { #### transformSource hook ```console -NODE_OPTIONS='--experimental-modules --experimental-loader ./custom-loader.mjs' node x.js +NODE_OPTIONS='--experimental-loader ./custom-loader.mjs' node x.js ``` > Note: The loaders API is being redesigned. This hook may disappear or its @@ -1733,11 +1727,11 @@ automatic extension resolution and importing from directories that include an index file use the `node` mode. ```bash -$ node --experimental-modules index.mjs +$ node index.mjs success! -$ node --experimental-modules index #Failure! +$ node index # Failure! Error: Cannot find module -$ node --experimental-modules --experimental-specifier-resolution=node index +$ node --experimental-specifier-resolution=node index success! ``` diff --git a/doc/api/vm.md b/doc/api/vm.md index 98f422cce3656c..1e1533b919e071 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -85,8 +85,8 @@ changes: * `importModuleDynamically` {Function} Called during evaluation of this module when `import()` is called. If this option is not specified, calls to `import()` will reject with [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. - This option is part of the experimental API for the `--experimental-modules` - flag, and should not be considered stable. + This option is part of the experimental modules API, and should not be + considered stable. * `specifier` {string} specifier passed to `import()` * `module` {vm.Module} * Returns: {Module Namespace Object|vm.Module} Returning a `vm.Module` is @@ -876,8 +876,8 @@ changes: * `importModuleDynamically` {Function} Called during evaluation of this module when `import()` is called. If this option is not specified, calls to `import()` will reject with [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. - This option is part of the experimental API for the `--experimental-modules` - flag, and should not be considered stable. + This option is part of the experimental modules API, and should not be + considered stable. * `specifier` {string} specifier passed to `import()` * `module` {vm.Module} * Returns: {Module Namespace Object|vm.Module} Returning a `vm.Module` is @@ -972,8 +972,8 @@ changes: * `importModuleDynamically` {Function} Called during evaluation of this module when `import()` is called. If this option is not specified, calls to `import()` will reject with [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. - This option is part of the experimental API for the `--experimental-modules` - flag, and should not be considered stable. + This option is part of the experimental modules API, and should not be + considered stable. * `specifier` {string} specifier passed to `import()` * `module` {vm.Module} * Returns: {Module Namespace Object|vm.Module} Returning a `vm.Module` is @@ -1048,8 +1048,8 @@ changes: * `importModuleDynamically` {Function} Called during evaluation of this module when `import()` is called. If this option is not specified, calls to `import()` will reject with [`ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`][]. - This option is part of the experimental API for the `--experimental-modules` - flag, and should not be considered stable. + This option is part of the experimental modules API, and should not be + considered stable. * `specifier` {string} specifier passed to `import()` * `module` {vm.Module} * Returns: {Module Namespace Object|vm.Module} Returning a `vm.Module` is diff --git a/doc/node.1 b/doc/node.1 index 7219fc10c767e8..3f992e131f7991 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -133,7 +133,7 @@ Specify the to use as a custom module loader. . .It Fl -experimental-modules -Enable experimental ES module support and caching modules. +Enable experimental latest experimental modules features. . .It Fl -experimental-policy Use the specified file as a security policy. diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 5422f1335dec33..fd8a4327a426ec 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -210,23 +210,21 @@ class NativeModule { } // Used by user-land module loaders to compile and load builtins. - compileForPublicLoader(needToSyncExports) { + compileForPublicLoader() { if (!this.canBeRequiredByUsers) { // No code because this is an assertion against bugs // eslint-disable-next-line no-restricted-syntax throw new Error(`Should not compile ${this.id} for public use`); } this.compileForInternalLoader(); - if (needToSyncExports) { - if (!this.exportKeys) { - // When using --expose-internals, we do not want to reflect the named - // exports from core modules as this can trigger unnecessary getters. - const internal = this.id.startsWith('internal/'); - this.exportKeys = internal ? [] : ObjectKeys(this.exports); - } - this.getESMFacade(); - this.syncExports(); + if (!this.exportKeys) { + // When using --expose-internals, we do not want to reflect the named + // exports from core modules as this can trigger unnecessary getters. + const internal = this.id.startsWith('internal/'); + this.exportKeys = internal ? [] : ObjectKeys(this.exports); } + this.getESMFacade(); + this.syncExports(); return this.exports; } diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 460c29c7584a46..3d5e0061daa8d1 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -408,24 +408,15 @@ function initializeESMLoader() { // Create this WeakMap in js-land because V8 has no C++ API for WeakMap. internalBinding('module_wrap').callbackMap = new SafeWeakMap(); - const experimentalModules = getOptionValue('--experimental-modules'); - const experimentalVMModules = getOptionValue('--experimental-vm-modules'); - if (experimentalModules || experimentalVMModules) { - if (experimentalModules) { - process.emitWarning( - 'The ESM module loader is experimental.', - 'ExperimentalWarning', undefined); - } - const { - setImportModuleDynamicallyCallback, - setInitializeImportMetaObjectCallback - } = internalBinding('module_wrap'); - const esm = require('internal/process/esm_loader'); - // Setup per-isolate callbacks that locate data or callbacks that we keep - // track of for different ESM modules. - setInitializeImportMetaObjectCallback(esm.initializeImportMetaObject); - setImportModuleDynamicallyCallback(esm.importModuleDynamicallyCallback); - } + const { + setImportModuleDynamicallyCallback, + setInitializeImportMetaObjectCallback + } = internalBinding('module_wrap'); + const esm = require('internal/process/esm_loader'); + // Setup per-isolate callbacks that locate data or callbacks that we keep + // track of for different ESM modules. + setInitializeImportMetaObjectCallback(esm.initializeImportMetaObject); + setImportModuleDynamicallyCallback(esm.importModuleDynamicallyCallback); } function initializeFrozenIntrinsics() { diff --git a/lib/internal/main/check_syntax.js b/lib/internal/main/check_syntax.js index f69e7b6ba5f38f..a3b9bf2923769e 100644 --- a/lib/internal/main/check_syntax.js +++ b/lib/internal/main/check_syntax.js @@ -47,23 +47,20 @@ if (process.argv[1] && process.argv[1] !== '-') { function checkSyntax(source, filename) { const { getOptionValue } = require('internal/options'); - const experimentalModules = getOptionValue('--experimental-modules'); - if (experimentalModules) { - let isModule = false; - if (filename === '[stdin]' || filename === '[eval]') { - isModule = getOptionValue('--input-type') === 'module'; - } else { - const { defaultResolve } = require('internal/modules/esm/resolve'); - const { defaultGetFormat } = require('internal/modules/esm/get_format'); - const { url } = defaultResolve(pathToFileURL(filename).toString()); - const { format } = defaultGetFormat(url); - isModule = format === 'module'; - } - if (isModule) { - const { ModuleWrap } = internalBinding('module_wrap'); - new ModuleWrap(filename, undefined, source, 0, 0); - return; - } + let isModule = false; + if (filename === '[stdin]' || filename === '[eval]') { + isModule = getOptionValue('--input-type') === 'module'; + } else { + const { defaultResolve } = require('internal/modules/esm/resolve'); + const { defaultGetFormat } = require('internal/modules/esm/get_format'); + const { url } = defaultResolve(pathToFileURL(filename).toString()); + const { format } = defaultGetFormat(url); + isModule = format === 'module'; + } + if (isModule) { + const { ModuleWrap } = internalBinding('module_wrap'); + new ModuleWrap(filename, undefined, source, 0, 0); + return; } wrapSafe(filename, source); diff --git a/lib/internal/main/run_main_module.js b/lib/internal/main/run_main_module.js index b085f2fd1cd9f3..ca5d1122c59d94 100644 --- a/lib/internal/main/run_main_module.js +++ b/lib/internal/main/run_main_module.js @@ -8,11 +8,10 @@ prepareMainThreadExecution(true); markBootstrapComplete(); -// Note: this loads the module through the ESM loader if -// --experimental-loader is provided or --experimental-modules is on -// and the module is determined to be an ES module. This hangs from the CJS -// module loader because we currently allow monkey-patching of the module -// loaders in the preloaded scripts through require('module'). +// Note: this loads the module through the ESM loader if the module is +// determined to be an ES module. This hangs from the CJS module loader +// because we currently allow monkey-patching of the module loaders +// in the preloaded scripts through require('module'). // runMain here might be monkey-patched by users in --require. // XXX: the monkey-patchability here should probably be deprecated. require('internal/modules/cjs/loader').Module.runMain(process.argv[1]); diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index df41f15ff58610..2d73219a77772c 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -9,8 +9,6 @@ const { ERR_UNKNOWN_BUILTIN_MODULE } = require('internal/errors').codes; const { NativeModule } = require('internal/bootstrap/loaders'); -const { getOptionValue } = require('internal/options'); -const experimentalModules = getOptionValue('--experimental-modules'); const { validateString } = require('internal/validators'); const path = require('path'); @@ -19,11 +17,11 @@ const { URL } = require('url'); const debug = require('internal/util/debuglog').debuglog('module'); -function loadNativeModule(filename, request, experimentalModules) { +function loadNativeModule(filename, request) { const mod = NativeModule.map.get(filename); if (mod) { debug('load native module %s', request); - mod.compileForPublicLoader(experimentalModules); + mod.compileForPublicLoader(); return mod; } } @@ -48,10 +46,7 @@ function makeRequireFunction(mod, redirects) { const href = destination.href; if (destination.protocol === 'node:') { const specifier = destination.pathname; - const mod = loadNativeModule( - specifier, - href, - experimentalModules); + const mod = loadNativeModule(specifier, href); if (mod && mod.canBeRequiredByUsers) { return mod.exports; } diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 0d7658ee7ae8fe..fc42eb033c923f 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -70,7 +70,6 @@ const { getOptionValue } = require('internal/options'); const enableSourceMaps = getOptionValue('--enable-source-maps'); const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); -const experimentalModules = getOptionValue('--experimental-modules'); const manifest = getOptionValue('--experimental-policy') ? require('internal/process/policy').manifest : null; @@ -395,7 +394,6 @@ function findLongestRegisteredExtension(filename) { } function trySelf(parentPath, request) { - if (!experimentalModules) return false; const { data: pkg, path: basePath } = readPackageScope(parentPath) || {}; if (!pkg || pkg.exports === undefined) return false; if (typeof pkg.name !== 'string') return false; @@ -444,7 +442,7 @@ function applyExports(basePath, expansion) { const mappingKey = `.${expansion}`; let pkgExports = readPackageExports(basePath); - if (pkgExports === undefined || pkgExports === null || !experimentalModules) + if (pkgExports === undefined || pkgExports === null) return false; if (isConditionalDotExportSugar(pkgExports, basePath)) @@ -849,7 +847,7 @@ Module._load = function(request, parent, isMain) { return cachedModule.exports; } - const mod = loadNativeModule(filename, request, experimentalModules); + const mod = loadNativeModule(filename, request); if (mod && mod.canBeRequiredByUsers) return mod.exports; // Don't call updateChildren(), Module constructor already does. @@ -988,31 +986,29 @@ Module.prototype.load = function(filename) { Module._extensions[extension](this, filename); this.loaded = true; - if (experimentalModules) { - const ESMLoader = asyncESM.ESMLoader; - const url = `${pathToFileURL(filename)}`; - const module = ESMLoader.moduleMap.get(url); - // Create module entry at load time to snapshot exports correctly - const exports = this.exports; - // Called from cjs translator - if (module !== undefined && module.module !== undefined) { - if (module.module.getStatus() >= kInstantiated) - module.module.setExport('default', exports); - } else { - // Preemptively cache - // We use a function to defer promise creation for async hooks. - ESMLoader.moduleMap.set( - url, - // Module job creation will start promises. - // We make it a function to lazily trigger those promises - // for async hooks compatibility. - () => new ModuleJob(ESMLoader, url, () => - new ModuleWrap(url, undefined, ['default'], function() { - this.setExport('default', exports); - }) - , false /* isMain */, false /* inspectBrk */) - ); - } + const ESMLoader = asyncESM.ESMLoader; + const url = `${pathToFileURL(filename)}`; + const module = ESMLoader.moduleMap.get(url); + // Create module entry at load time to snapshot exports correctly + const exports = this.exports; + // Called from cjs translator + if (module !== undefined && module.module !== undefined) { + if (module.module.getStatus() >= kInstantiated) + module.module.setExport('default', exports); + } else { + // Preemptively cache + // We use a function to defer promise creation for async hooks. + ESMLoader.moduleMap.set( + url, + // Module job creation will start promises. + // We make it a function to lazily trigger those promises + // for async hooks compatibility. + () => new ModuleJob(ESMLoader, url, () => + new ModuleWrap(url, undefined, ['default'], function() { + this.setExport('default', exports); + }) + , false /* isMain */, false /* inspectBrk */) + ); } }; @@ -1046,10 +1042,10 @@ function wrapSafe(filename, content, cjsModuleInstance) { filename, lineOffset: 0, displayErrors: true, - importModuleDynamically: experimentalModules ? async (specifier) => { + importModuleDynamically: async (specifier) => { const loader = asyncESM.ESMLoader; return loader.import(specifier, normalizeReferrerURL(filename)); - } : undefined, + }, }); } @@ -1073,20 +1069,18 @@ function wrapSafe(filename, content, cjsModuleInstance) { ] ); } catch (err) { - if (experimentalModules && process.mainModule === cjsModuleInstance) + if (process.mainModule === cjsModuleInstance) enrichCJSError(err); throw err; } - if (experimentalModules) { - const { callbackMap } = internalBinding('module_wrap'); - callbackMap.set(compiled.cacheKey, { - importModuleDynamically: async (specifier) => { - const loader = asyncESM.ESMLoader; - return loader.import(specifier, normalizeReferrerURL(filename)); - } - }); - } + const { callbackMap } = internalBinding('module_wrap'); + callbackMap.set(compiled.cacheKey, { + importModuleDynamically: async (specifier) => { + const loader = asyncESM.ESMLoader; + return loader.import(specifier, normalizeReferrerURL(filename)); + } + }); return compiled.function; } @@ -1296,8 +1290,6 @@ Module.syncBuiltinESMExports = function syncBuiltinESMExports() { Module.Module = Module; // We have to load the esm things after module.exports! -if (experimentalModules) { - ModuleJob = require('internal/modules/esm/module_job'); - asyncESM = require('internal/process/esm_loader'); - ({ ModuleWrap, kInstantiated } = internalBinding('module_wrap')); -} +asyncESM = require('internal/process/esm_loader'); +ModuleJob = require('internal/modules/esm/module_job'); +({ ModuleWrap, kInstantiated } = internalBinding('module_wrap')); diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js index 48d0e8eee2bc6f..d18a1a295714b8 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js @@ -21,9 +21,6 @@ function resolveMainPath(main) { } function shouldUseESMLoader(mainPath) { - const experimentalModules = getOptionValue('--experimental-modules'); - if (!experimentalModules) - return false; const userLoader = getOptionValue('--experimental-loader'); if (userLoader) return true; diff --git a/lib/internal/process/esm_loader.js b/lib/internal/process/esm_loader.js index ce6a7e756263c1..53302f75baa669 100644 --- a/lib/internal/process/esm_loader.js +++ b/lib/internal/process/esm_loader.js @@ -42,6 +42,9 @@ let calledInitialize = false; exports.initializeLoader = initializeLoader; async function initializeLoader() { assert(calledInitialize === false); + process.emitWarning( + 'The ESM module loader is experimental.', + 'ExperimentalWarning', undefined); calledInitialize = true; if (!userLoader) return; diff --git a/lib/repl.js b/lib/repl.js index fdb77bcd7765ed..5fdf4ffb9de8db 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -315,11 +315,7 @@ function REPLServer(prompt, } function defaultEval(code, context, file, cb) { - const { getOptionValue } = require('internal/options'); - const experimentalModules = getOptionValue('--experimental-modules'); - const asyncESM = experimentalModules ? - require('internal/process/esm_loader') : - null; + const asyncESM = require('internal/process/esm_loader'); let result, script, wrappedErr; let err = null; @@ -373,9 +369,9 @@ function REPLServer(prompt, script = vm.createScript(code, { filename: file, displayErrors: true, - importModuleDynamically: experimentalModules ? async (specifier) => { + importModuleDynamically: async (specifier) => { return asyncESM.ESMLoader.import(specifier, parentURL); - } : undefined + } }); } catch (e) { debug('parse error %j', code, e); diff --git a/src/node_options.cc b/src/node_options.cc index dbb3252780d6ba..fab1f8899ef91f 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -79,14 +79,6 @@ void PerIsolateOptions::CheckOptions(std::vector* errors) { } void EnvironmentOptions::CheckOptions(std::vector* errors) { - if (experimental_import_meta_resolve && !experimental_modules) { - errors->push_back("--experimental-meta-resolve requires " - "--experimental-modules be enabled"); - } - if (!userland_loader.empty() && !experimental_modules) { - errors->push_back("--experimental-loader requires " - "--experimental-modules be enabled"); - } if (has_policy_integrity_string && experimental_policy.empty()) { errors->push_back("--policy-integrity requires " "--experimental-policy be enabled"); @@ -96,30 +88,12 @@ void EnvironmentOptions::CheckOptions(std::vector* errors) { } if (!module_type.empty()) { - if (!experimental_modules) { - errors->push_back("--input-type requires " - "--experimental-modules to be enabled"); - } if (module_type != "commonjs" && module_type != "module") { errors->push_back("--input-type must be \"module\" or \"commonjs\""); } } - if (experimental_json_modules && !experimental_modules) { - errors->push_back("--experimental-json-modules requires " - "--experimental-modules be enabled"); - } - - if (experimental_wasm_modules && !experimental_modules) { - errors->push_back("--experimental-wasm-modules requires " - "--experimental-modules be enabled"); - } - if (!es_module_specifier_resolution.empty()) { - if (!experimental_modules) { - errors->push_back("--es-module-specifier-resolution requires " - "--experimental-modules be enabled"); - } if (!experimental_specifier_resolution.empty()) { errors->push_back( "bad option: cannot use --es-module-specifier-resolution" @@ -133,10 +107,6 @@ void EnvironmentOptions::CheckOptions(std::vector* errors) { } } } else if (!experimental_specifier_resolution.empty()) { - if (!experimental_modules) { - errors->push_back("--experimental-specifier-resolution requires " - "--experimental-modules be enabled"); - } if (experimental_specifier_resolution != "node" && experimental_specifier_resolution != "explicit") { errors->push_back( @@ -314,13 +284,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { &EnvironmentOptions::experimental_json_modules, kAllowedInEnvironment); AddOption("--experimental-loader", - "(with --experimental-modules) use the specified file as a " - "custom loader", + "use the specified module as a custom loader", &EnvironmentOptions::userland_loader, kAllowedInEnvironment); AddAlias("--loader", "--experimental-loader"); AddOption("--experimental-modules", - "experimental ES Module support and caching modules", + "experimental modules features", &EnvironmentOptions::experimental_modules, kAllowedInEnvironment); AddOption("--experimental-wasm-modules", diff --git a/test/common/index.mjs b/test/common/index.mjs index e9227ebff7def9..96e6699e3c6f99 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules /* eslint-disable node-core/require-common-first, node-core/required-modules */ import { createRequire } from 'module'; diff --git a/test/es-module/test-esm-basic-imports.mjs b/test/es-module/test-esm-basic-imports.mjs index c21804d78b292b..5009fbadb39657 100644 --- a/test/es-module/test-esm-basic-imports.mjs +++ b/test/es-module/test-esm-basic-imports.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; import ok from '../fixtures/es-modules/test-esm-ok.mjs'; diff --git a/test/es-module/test-esm-cjs-load-error-note.mjs b/test/es-module/test-esm-cjs-load-error-note.mjs index ce0d1d796969d7..c0ac9393a8ddd5 100644 --- a/test/es-module/test-esm-cjs-load-error-note.mjs +++ b/test/es-module/test-esm-cjs-load-error-note.mjs @@ -1,5 +1,3 @@ -// Flags: --experimental-modules - import { mustCall } from '../common/index.mjs'; import assert from 'assert'; import fixtures from '../common/fixtures.js'; @@ -20,7 +18,7 @@ const expectedNote = 'To load an ES module, ' + const expectedCode = 1; -const pExport1 = spawn(process.execPath, ['--experimental-modules', Export1]); +const pExport1 = spawn(process.execPath, [Export1]); let pExport1Stderr = ''; pExport1.stderr.setEncoding('utf8'); pExport1.stderr.on('data', (data) => { @@ -33,7 +31,7 @@ pExport1.on('close', mustCall((code) => { })); -const pExport2 = spawn(process.execPath, ['--experimental-modules', Export2]); +const pExport2 = spawn(process.execPath, [Export2]); let pExport2Stderr = ''; pExport2.stderr.setEncoding('utf8'); pExport2.stderr.on('data', (data) => { @@ -44,21 +42,8 @@ pExport2.on('close', mustCall((code) => { assert.ok(pExport2Stderr.includes(expectedNote), `${expectedNote} not found in ${pExport2Stderr}`); })); -// The flag --experimental-modules is not used here -// the note must not be included in the output -const pExport3 = spawn(process.execPath, [Export1]); -let pExport3Stderr = ''; -pExport3.stderr.setEncoding('utf8'); -pExport3.stderr.on('data', (data) => { - pExport3Stderr += data; -}); -pExport3.on('close', mustCall((code) => { - assert.strictEqual(code, expectedCode); - assert.ok(!pExport3Stderr.includes(expectedNote), - `${expectedNote} must not be included in ${pExport3Stderr}`); -})); -const pImport1 = spawn(process.execPath, ['--experimental-modules', Import1]); +const pImport1 = spawn(process.execPath, [Import1]); let pImport1Stderr = ''; pImport1.stderr.setEncoding('utf8'); pImport1.stderr.on('data', (data) => { @@ -71,7 +56,7 @@ pImport1.on('close', mustCall((code) => { })); // Note this test shouldn't include the note -const pImport2 = spawn(process.execPath, ['--experimental-modules', Import2]); +const pImport2 = spawn(process.execPath, [Import2]); let pImport2Stderr = ''; pImport2.stderr.setEncoding('utf8'); pImport2.stderr.on('data', (data) => { @@ -84,7 +69,7 @@ pImport2.on('close', mustCall((code) => { `${expectedNote} must not be included in ${pImport2Stderr}`); })); -const pImport3 = spawn(process.execPath, ['--experimental-modules', Import3]); +const pImport3 = spawn(process.execPath, [Import3]); let pImport3Stderr = ''; pImport3.stderr.setEncoding('utf8'); pImport3.stderr.on('data', (data) => { @@ -97,7 +82,7 @@ pImport3.on('close', mustCall((code) => { })); -const pImport4 = spawn(process.execPath, ['--experimental-modules', Import4]); +const pImport4 = spawn(process.execPath, [Import4]); let pImport4Stderr = ''; pImport4.stderr.setEncoding('utf8'); pImport4.stderr.on('data', (data) => { @@ -110,7 +95,7 @@ pImport4.on('close', mustCall((code) => { })); // Must exit with zero and show note -const pImport5 = spawn(process.execPath, ['--experimental-modules', Import5]); +const pImport5 = spawn(process.execPath, [Import5]); let pImport5Stderr = ''; pImport5.stderr.setEncoding('utf8'); pImport5.stderr.on('data', (data) => { @@ -121,16 +106,3 @@ pImport5.on('close', mustCall((code) => { assert.ok(!pImport5Stderr.includes(expectedNote), `${expectedNote} must not be included in ${pImport5Stderr}`); })); - -// Must exit with zero and not show note -const pImport6 = spawn(process.execPath, [Import1]); -let pImport6Stderr = ''; -pImport6.stderr.setEncoding('utf8'); -pImport6.stderr.on('data', (data) => { - pImport6Stderr += data; -}); -pImport6.on('close', mustCall((code) => { - assert.strictEqual(code, expectedCode); - assert.ok(!pImport6Stderr.includes(expectedNote), - `${expectedNote} must not be included in ${pImport6Stderr}`); -})); diff --git a/test/es-module/test-esm-cjs-main.js b/test/es-module/test-esm-cjs-main.js index 8308308a2dce72..92f4124ccaab8a 100644 --- a/test/es-module/test-esm-cjs-main.js +++ b/test/es-module/test-esm-cjs-main.js @@ -7,12 +7,8 @@ const assert = require('assert'); const entry = fixtures.path('/es-modules/cjs.js'); -const child = spawn(process.execPath, ['--experimental-modules', entry]); -let stderr = ''; +const child = spawn(process.execPath, [entry]); child.stderr.setEncoding('utf8'); -child.stderr.on('data', (data) => { - stderr += data; -}); let stdout = ''; child.stdout.setEncoding('utf8'); child.stdout.on('data', (data) => { @@ -22,6 +18,4 @@ child.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); assert.strictEqual(stdout, 'executed\n'); - assert.strictEqual(stderr, `(node:${child.pid}) ` + - 'ExperimentalWarning: The ESM module loader is experimental.\n'); })); diff --git a/test/es-module/test-esm-cyclic-dynamic-import.mjs b/test/es-module/test-esm-cyclic-dynamic-import.mjs index 03d405baf3ce9c..6f831470b71853 100644 --- a/test/es-module/test-esm-cyclic-dynamic-import.mjs +++ b/test/es-module/test-esm-cyclic-dynamic-import.mjs @@ -1,3 +1,2 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import('./test-esm-cyclic-dynamic-import.mjs'); diff --git a/test/es-module/test-esm-data-urls.js b/test/es-module/test-esm-data-urls.js index a7b917ec74e297..61da442c9e081c 100644 --- a/test/es-module/test-esm-data-urls.js +++ b/test/es-module/test-esm-data-urls.js @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-json-modules +// Flags: --experimental-json-modules 'use strict'; const common = require('../common'); const assert = require('assert'); diff --git a/test/es-module/test-esm-default-type.mjs b/test/es-module/test-esm-default-type.mjs index 7e63dab3490d04..4b758df9166986 100644 --- a/test/es-module/test-esm-default-type.mjs +++ b/test/es-module/test-esm-default-type.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import { strictEqual } from 'assert'; diff --git a/test/es-module/test-esm-double-encoding.mjs b/test/es-module/test-esm-double-encoding.mjs index 2edfc8add5d2db..e46249f128203c 100644 --- a/test/es-module/test-esm-double-encoding.mjs +++ b/test/es-module/test-esm-double-encoding.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; // Assert we can import files with `%` in their pathname. diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index a08e66dad3f820..e72922d31c0b18 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -1,5 +1,3 @@ -// Flags: --experimental-modules - 'use strict'; const common = require('../common'); const assert = require('assert'); diff --git a/test/es-module/test-esm-encoded-path-native.js b/test/es-module/test-esm-encoded-path-native.js index a3106742d9ee8e..b8f5719b6089ee 100644 --- a/test/es-module/test-esm-encoded-path-native.js +++ b/test/es-module/test-esm-encoded-path-native.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { spawn } = require('child_process'); const native = fixtures.path('es-module-url/native.mjs'); -const child = spawn(process.execPath, ['--experimental-modules', native]); +const child = spawn(process.execPath, [native]); child.on('exit', (code) => { assert.strictEqual(code, 1); }); diff --git a/test/es-module/test-esm-encoded-path.mjs b/test/es-module/test-esm-encoded-path.mjs index efb681ef0b4dfe..351cb7eab887b4 100644 --- a/test/es-module/test-esm-encoded-path.mjs +++ b/test/es-module/test-esm-encoded-path.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; // ./test-esm-ok.mjs diff --git a/test/es-module/test-esm-error-cache.js b/test/es-module/test-esm-error-cache.js index 26e0d170ac2e1b..b13e793626876a 100644 --- a/test/es-module/test-esm-error-cache.js +++ b/test/es-module/test-esm-error-cache.js @@ -1,5 +1,3 @@ -// Flags: --experimental-modules - 'use strict'; require('../common'); diff --git a/test/es-module/test-esm-example-loader.js b/test/es-module/test-esm-example-loader.js index 0da1d34d2ad6fc..b85de4e64c4abc 100644 --- a/test/es-module/test-esm-example-loader.js +++ b/test/es-module/test-esm-example-loader.js @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/example-loader.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/example-loader.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import assert from 'assert'; import ok from '../fixtures/es-modules/test-esm-ok.mjs'; diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs index de1358e968b213..bf702345c24207 100644 --- a/test/es-module/test-esm-exports.mjs +++ b/test/es-module/test-esm-exports.mjs @@ -1,5 +1,3 @@ -// Flags: --experimental-modules - import { mustCall } from '../common/index.mjs'; import { ok, deepStrictEqual, strictEqual } from 'assert'; diff --git a/test/es-module/test-esm-flagged-self.js b/test/es-module/test-esm-flagged-self.js deleted file mode 100644 index 43a0c4f9684bf0..00000000000000 --- a/test/es-module/test-esm-flagged-self.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -require('../common'); -const assert = require('assert'); -const path = require('path'); -const { createRequireFromPath } = require('module'); - -const fixturesRequire = - createRequireFromPath(path.resolve(__dirname, '../fixtures/_')); - -try { - fixturesRequire('pkgexports/resolve-self'); - assert(false); -} catch (e) { - assert.strictEqual(e.code, 'MODULE_NOT_FOUND'); -} diff --git a/test/es-module/test-esm-forbidden-globals.mjs b/test/es-module/test-esm-forbidden-globals.mjs index b66f278a8a9bb8..2f1914e48631b5 100644 --- a/test/es-module/test-esm-forbidden-globals.mjs +++ b/test/es-module/test-esm-forbidden-globals.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; // eslint-disable-next-line no-undef diff --git a/test/es-module/test-esm-get-source-loader.mjs b/test/es-module/test-esm-get-source-loader.mjs index 12ec5d0173db9e..66bac969a47d8f 100644 --- a/test/es-module/test-esm-get-source-loader.mjs +++ b/test/es-module/test-esm-get-source-loader.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/get-source.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/get-source.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import assert from 'assert'; import { message } from '../fixtures/es-modules/message.mjs'; diff --git a/test/es-module/test-esm-import-meta-resolve.mjs b/test/es-module/test-esm-import-meta-resolve.mjs index 3d9dae48676c50..faf9320a82745a 100644 --- a/test/es-module/test-esm-import-meta-resolve.mjs +++ b/test/es-module/test-esm-import-meta-resolve.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-import-meta-resolve +// Flags: --experimental-import-meta-resolve import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-import-meta.mjs b/test/es-module/test-esm-import-meta.mjs index 54c14a44f5e281..0151177b21c302 100644 --- a/test/es-module/test-esm-import-meta.mjs +++ b/test/es-module/test-esm-import-meta.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-invalid-extension.js b/test/es-module/test-esm-invalid-extension.js index 414b68776278ac..cca7704f7994f0 100644 --- a/test/es-module/test-esm-invalid-extension.js +++ b/test/es-module/test-esm-invalid-extension.js @@ -4,7 +4,7 @@ const fixtures = require('../common/fixtures'); const assert = require('assert'); const { spawnSync } = require('child_process'); const fixture = fixtures.path('/es-modules/import-invalid-ext.mjs'); -const child = spawnSync(process.execPath, ['--experimental-modules', fixture]); +const child = spawnSync(process.execPath, [fixture]); const errMsg = 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension'; assert.strictEqual(child.status, 1); diff --git a/test/es-module/test-esm-json-cache.mjs b/test/es-module/test-esm-json-cache.mjs index d1fee4f444c2c0..d08f852e255a78 100644 --- a/test/es-module/test-esm-json-cache.mjs +++ b/test/es-module/test-esm-json-cache.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-json-modules +// Flags: --experimental-json-modules import '../common/index.mjs'; import { strictEqual, deepStrictEqual } from 'assert'; diff --git a/test/es-module/test-esm-json.mjs b/test/es-module/test-esm-json.mjs index 3f4608d09d9604..ddcc7cb33e709f 100644 --- a/test/es-module/test-esm-json.mjs +++ b/test/es-module/test-esm-json.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-json-modules +// Flags: --experimental-json-modules import '../common/index.mjs'; import { path } from '../common/fixtures.mjs'; import { strictEqual, ok } from 'assert'; @@ -10,7 +10,6 @@ strictEqual(secret.ofLife, 42); // Test warning message const child = spawn(process.execPath, [ - '--experimental-modules', '--experimental-json-modules', path('/es-modules/json-modules.mjs') ]); diff --git a/test/es-module/test-esm-live-binding.mjs b/test/es-module/test-esm-live-binding.mjs index 4000a621a2bd04..ff58db31f144a3 100644 --- a/test/es-module/test-esm-live-binding.mjs +++ b/test/es-module/test-esm-live-binding.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; import { syncBuiltinESMExports } from 'module'; diff --git a/test/es-module/test-esm-loader-cache-clearing.js b/test/es-module/test-esm-loader-cache-clearing.js index ec22b6a6bb871e..4b5f36cf37ec3b 100644 --- a/test/es-module/test-esm-loader-cache-clearing.js +++ b/test/es-module/test-esm-loader-cache-clearing.js @@ -1,4 +1,3 @@ -// Flags: --experimental-modules 'use strict'; require('../common'); diff --git a/test/es-module/test-esm-loader-custom-condition.mjs b/test/es-module/test-esm-loader-custom-condition.mjs index 6e85846c66f5e8..26d1db4842f621 100644 --- a/test/es-module/test-esm-loader-custom-condition.mjs +++ b/test/es-module/test-esm-loader-custom-condition.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-with-custom-condition.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-with-custom-condition.mjs import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-loader-dependency.mjs b/test/es-module/test-esm-loader-dependency.mjs index dadc3bd84ae1d3..54327b478bf462 100644 --- a/test/es-module/test-esm-loader-dependency.mjs +++ b/test/es-module/test-esm-loader-dependency.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-with-dep.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-with-dep.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import '../fixtures/es-modules/test-esm-ok.mjs'; diff --git a/test/es-module/test-esm-loader-get-format.mjs b/test/es-module/test-esm-loader-get-format.mjs index 4fb40db39f75dd..2a252439f91ce4 100644 --- a/test/es-module/test-esm-loader-get-format.mjs +++ b/test/es-module/test-esm-loader-get-format.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-get-format.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-get-format.mjs import { mustCall, mustNotCall } from '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-loader-invalid-format.mjs b/test/es-module/test-esm-loader-invalid-format.mjs index d7a91aaa38b8e3..64237f7af243af 100644 --- a/test/es-module/test-esm-loader-invalid-format.mjs +++ b/test/es-module/test-esm-loader-invalid-format.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-invalid-format.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-invalid-format.mjs import { expectsError, mustCall } from '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-loader-invalid-url.mjs b/test/es-module/test-esm-loader-invalid-url.mjs index 74dba3485bb2ab..e9f04d0af4d4fe 100644 --- a/test/es-module/test-esm-loader-invalid-url.mjs +++ b/test/es-module/test-esm-loader-invalid-url.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-invalid-url.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-invalid-url.mjs import { expectsError, mustCall } from '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs index 5767af7affe1fa..62781c37d48240 100644 --- a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs +++ b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs import { expectsError } from '../common/index.mjs'; import('test').catch(expectsError({ diff --git a/test/es-module/test-esm-loader-modulemap.js b/test/es-module/test-esm-loader-modulemap.js index 2d601cd99f1b4b..a4d56a2c2fda1c 100644 --- a/test/es-module/test-esm-loader-modulemap.js +++ b/test/es-module/test-esm-loader-modulemap.js @@ -1,5 +1,5 @@ 'use strict'; -// Flags: --expose-internals --experimental-modules +// Flags: --expose-internals // This test ensures that the type checking of ModuleMap throws // errors appropriately diff --git a/test/es-module/test-esm-loader-side-effect.mjs b/test/es-module/test-esm-loader-side-effect.mjs index 3ac71448252e97..f76b10700ddc8f 100644 --- a/test/es-module/test-esm-loader-side-effect.mjs +++ b/test/es-module/test-esm-loader-side-effect.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-side-effect.mjs --require ./test/fixtures/es-module-loaders/loader-side-effect-require-preload.js +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-side-effect.mjs --require ./test/fixtures/es-module-loaders/loader-side-effect-require-preload.js import { allowGlobals, mustCall } from '../common/index.mjs'; import assert from 'assert'; import { fileURLToPath } from 'url'; diff --git a/test/es-module/test-esm-main-lookup.mjs b/test/es-module/test-esm-main-lookup.mjs index cbc6424dd2ff1c..2023a105e4dc42 100644 --- a/test/es-module/test-esm-main-lookup.mjs +++ b/test/es-module/test-esm-main-lookup.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-named-exports.mjs b/test/es-module/test-esm-named-exports.mjs index 6c8030826970a8..7d8d1080082401 100644 --- a/test/es-module/test-esm-named-exports.mjs +++ b/test/es-module/test-esm-named-exports.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs import '../common/index.mjs'; import { readFile } from 'fs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-namespace.mjs b/test/es-module/test-esm-namespace.mjs index 094a9e972cbbad..9ce0f9686d1668 100644 --- a/test/es-module/test-esm-namespace.mjs +++ b/test/es-module/test-esm-namespace.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import * as fs from 'fs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-non-js.js b/test/es-module/test-esm-non-js.js index 3a41b7228ca81b..3e572809bbdf35 100644 --- a/test/es-module/test-esm-non-js.js +++ b/test/es-module/test-esm-non-js.js @@ -7,7 +7,7 @@ const assert = require('assert'); const entry = require.resolve('./test-esm-json.mjs'); // Verify non-js extensions fail for ESM -const child = spawn(process.execPath, ['--experimental-modules', entry]); +const child = spawn(process.execPath, [entry]); let stderr = ''; child.stderr.setEncoding('utf8'); diff --git a/test/es-module/test-esm-nowarn-exports.mjs b/test/es-module/test-esm-nowarn-exports.mjs index 0c5ae17e764797..13bfaf9b4f3527 100644 --- a/test/es-module/test-esm-nowarn-exports.mjs +++ b/test/es-module/test-esm-nowarn-exports.mjs @@ -1,11 +1,9 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import { path } from '../common/fixtures.mjs'; import { strictEqual, ok } from 'assert'; import { spawn } from 'child_process'; const child = spawn(process.execPath, [ - '--experimental-modules', '--experimental-import-meta-resolve', path('/es-modules/import-resolve-exports.mjs') ]); diff --git a/test/es-module/test-esm-pkgname.mjs b/test/es-module/test-esm-pkgname.mjs index 046a12dd1a12da..06b5d2d104df63 100644 --- a/test/es-module/test-esm-pkgname.mjs +++ b/test/es-module/test-esm-pkgname.mjs @@ -1,5 +1,3 @@ -// Flags: --experimental-modules - import { mustCall } from '../common/index.mjs'; import { strictEqual } from 'assert'; diff --git a/test/es-module/test-esm-preserve-symlinks-main.js b/test/es-module/test-esm-preserve-symlinks-main.js index 239fdddc2e8d79..877066a6a4548e 100644 --- a/test/es-module/test-esm-preserve-symlinks-main.js +++ b/test/es-module/test-esm-preserve-symlinks-main.js @@ -53,5 +53,5 @@ function doTest(flags, done) { // First test the commonjs module loader doTest([], () => { // Now test the new loader - doTest(['--experimental-modules'], () => {}); + doTest([], () => {}); }); diff --git a/test/es-module/test-esm-preserve-symlinks-not-found-plain.mjs b/test/es-module/test-esm-preserve-symlinks-not-found-plain.mjs index 1dcae4b8aef4a8..7a538e44c072e0 100644 --- a/test/es-module/test-esm-preserve-symlinks-not-found-plain.mjs +++ b/test/es-module/test-esm-preserve-symlinks-not-found-plain.mjs @@ -1,3 +1,3 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import './not-found.js'; diff --git a/test/es-module/test-esm-preserve-symlinks-not-found.mjs b/test/es-module/test-esm-preserve-symlinks-not-found.mjs index 68e1b53eeb1d75..722dc467d19273 100644 --- a/test/es-module/test-esm-preserve-symlinks-not-found.mjs +++ b/test/es-module/test-esm-preserve-symlinks-not-found.mjs @@ -1,3 +1,3 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/not-found-assert-loader.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import './not-found.mjs'; diff --git a/test/es-module/test-esm-preserve-symlinks.js b/test/es-module/test-esm-preserve-symlinks.js index 28cba3e7022c1a..a91373b0c05b93 100644 --- a/test/es-module/test-esm-preserve-symlinks.js +++ b/test/es-module/test-esm-preserve-symlinks.js @@ -32,7 +32,7 @@ try { } spawn(process.execPath, - ['--experimental-modules', '--preserve-symlinks', entry], + ['--preserve-symlinks', entry], { stdio: 'inherit' }).on('exit', (code) => { assert.strictEqual(code, 0); }); diff --git a/test/es-module/test-esm-process.mjs b/test/es-module/test-esm-process.mjs index a2b0d31f1efa27..8fa006a304ed2f 100644 --- a/test/es-module/test-esm-process.mjs +++ b/test/es-module/test-esm-process.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; import process from 'process'; diff --git a/test/es-module/test-esm-repl.js b/test/es-module/test-esm-repl.js index daef48d8e1f58b..653927b241694e 100644 --- a/test/es-module/test-esm-repl.js +++ b/test/es-module/test-esm-repl.js @@ -4,7 +4,6 @@ const assert = require('assert'); const { spawn } = require('child_process'); const child = spawn(process.execPath, [ - '--experimental-modules', '--interactive' ]); child.stdin.end(` diff --git a/test/es-module/test-esm-require-cache.mjs b/test/es-module/test-esm-require-cache.mjs index 8c126c39e0eefe..1cfcf8e2a4b416 100644 --- a/test/es-module/test-esm-require-cache.mjs +++ b/test/es-module/test-esm-require-cache.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import { createRequire } from '../common/index.mjs'; import assert from 'assert'; // diff --git a/test/es-module/test-esm-resolve-hook.mjs b/test/es-module/test-esm-resolve-hook.mjs index 00c8e440f42964..39b11e02739d4b 100644 --- a/test/es-module/test-esm-resolve-hook.mjs +++ b/test/es-module/test-esm-resolve-hook.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/js-loader.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/js-loader.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import { namedExport } from '../fixtures/es-module-loaders/js-as-esm.js'; import assert from 'assert'; diff --git a/test/es-module/test-esm-scope-node-modules.mjs b/test/es-module/test-esm-scope-node-modules.mjs index 8358da5c765288..0be4194aeb9b4d 100644 --- a/test/es-module/test-esm-scope-node-modules.mjs +++ b/test/es-module/test-esm-scope-node-modules.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import cjs from '../fixtures/baz.js'; import { message } from '../fixtures/es-modules/message.mjs'; diff --git a/test/es-module/test-esm-shared-loader-dep.mjs b/test/es-module/test-esm-shared-loader-dep.mjs index b02e557d34bc29..e0015bd0c755d7 100644 --- a/test/es-module/test-esm-shared-loader-dep.mjs +++ b/test/es-module/test-esm-shared-loader-dep.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-shared-dep.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-shared-dep.mjs import { createRequire } from '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-shebang.mjs b/test/es-module/test-esm-shebang.mjs index 1d22551bd7a4be..6b77151dd78406 100644 --- a/test/es-module/test-esm-shebang.mjs +++ b/test/es-module/test-esm-shebang.mjs @@ -1,5 +1,4 @@ #! }]) // isn't js -// Flags: --experimental-modules import '../common/index.mjs'; const isJs = true; diff --git a/test/es-module/test-esm-snapshot.mjs b/test/es-module/test-esm-snapshot.mjs index 99767f10e2846e..e2695d20a81747 100644 --- a/test/es-module/test-esm-snapshot.mjs +++ b/test/es-module/test-esm-snapshot.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import '../fixtures/es-modules/esm-snapshot-mutator.js'; import one from '../fixtures/es-modules/esm-snapshot.js'; diff --git a/test/es-module/test-esm-specifiers-both-flags.mjs b/test/es-module/test-esm-specifiers-both-flags.mjs index 5cdeed0c82a888..a434684589dc07 100644 --- a/test/es-module/test-esm-specifiers-both-flags.mjs +++ b/test/es-module/test-esm-specifiers-both-flags.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import { mustCall } from '../common/index.mjs'; import { exec } from 'child_process'; import assert from 'assert'; @@ -7,8 +6,7 @@ const expectedError = 'cannot use --es-module-specifier-resolution ' + 'and --experimental-specifier-resolution at the same time'; -const flags = '--experimental-modules ' + - '--es-module-specifier-resolution=node ' + +const flags = '--es-module-specifier-resolution=node ' + '--experimental-specifier-resolution=node'; exec(`${process.execPath} ${flags}`, mustCall((error) => { diff --git a/test/es-module/test-esm-specifiers-legacy-flag.mjs b/test/es-module/test-esm-specifiers-legacy-flag.mjs index 03388493f0b8cb..fcf0c915b649f0 100644 --- a/test/es-module/test-esm-specifiers-legacy-flag.mjs +++ b/test/es-module/test-esm-specifiers-legacy-flag.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --es-module-specifier-resolution=node +// Flags: --es-module-specifier-resolution=node import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-specifiers.mjs b/test/es-module/test-esm-specifiers.mjs index cf9a50353878de..5e436f21b74cc6 100644 --- a/test/es-module/test-esm-specifiers.mjs +++ b/test/es-module/test-esm-specifiers.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-specifier-resolution=node +// Flags: --experimental-specifier-resolution=node import { mustNotCall } from '../common/index.mjs'; import assert from 'assert'; import path from 'path'; @@ -49,11 +49,9 @@ main().catch(mustNotCall); '../../fixtures/es-module-specifiers', item, ); - spawn(process.execPath, [ - '--experimental-modules', - '--es-module-specifier-resolution=node', - modulePath - ], { stdio: 'inherit' }).on('exit', (code) => { + spawn(process.execPath, + ['--es-module-specifier-resolution=node', modulePath], + { stdio: 'inherit' }).on('exit', (code) => { assert.strictEqual(code, 0); }); }); diff --git a/test/es-module/test-esm-symlink-main.js b/test/es-module/test-esm-symlink-main.js index 871180f5ccf4bb..48b4d8bbe65daf 100644 --- a/test/es-module/test-esm-symlink-main.js +++ b/test/es-module/test-esm-symlink-main.js @@ -19,7 +19,7 @@ try { } spawn(process.execPath, - ['--experimental-modules', '--preserve-symlinks', symlinkPath], + ['--preserve-symlinks', symlinkPath], { stdio: 'inherit' }).on('exit', (code) => { assert.strictEqual(code, 0); }); diff --git a/test/es-module/test-esm-symlink-type.js b/test/es-module/test-esm-symlink-type.js index 6159ebecd18be4..1f46dce17f2e46 100644 --- a/test/es-module/test-esm-symlink-type.js +++ b/test/es-module/test-esm-symlink-type.js @@ -48,8 +48,8 @@ symlinks.forEach((symlink) => { fs.symlinkSync(symlink.target, mainPath); const flags = [ - '--experimental-modules', - '--experimental-modules --preserve-symlinks-main' + '', + '--preserve-symlinks-main' ]; flags.forEach((nodeOptions) => { const opts = { diff --git a/test/es-module/test-esm-symlink.js b/test/es-module/test-esm-symlink.js index 9b9eb98cd98406..139e6820ed5354 100644 --- a/test/es-module/test-esm-symlink.js +++ b/test/es-module/test-esm-symlink.js @@ -41,7 +41,7 @@ try { common.skip('insufficient privileges for symlinks'); } -spawn(process.execPath, ['--experimental-modules', entry], +spawn(process.execPath, [entry], { stdio: 'inherit' }).on('exit', (code) => { assert.strictEqual(code, 0); }); diff --git a/test/es-module/test-esm-throw-undefined.mjs b/test/es-module/test-esm-throw-undefined.mjs index 4c091e61532640..c4c25fd12d675c 100644 --- a/test/es-module/test-esm-throw-undefined.mjs +++ b/test/es-module/test-esm-throw-undefined.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; diff --git a/test/es-module/test-esm-transform-source-loader.mjs b/test/es-module/test-esm-transform-source-loader.mjs index 03c7f67431c888..e6d4affea495de 100644 --- a/test/es-module/test-esm-transform-source-loader.mjs +++ b/test/es-module/test-esm-transform-source-loader.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/transform-source.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/transform-source.mjs /* eslint-disable node-core/require-common-first, node-core/required-modules */ import assert from 'assert'; import { message } from '../fixtures/es-modules/message.mjs'; diff --git a/test/es-module/test-esm-type-flag-errors.js b/test/es-module/test-esm-type-flag-errors.js index fd09edc4648b75..e0dedc16cabf8c 100644 --- a/test/es-module/test-esm-type-flag-errors.js +++ b/test/es-module/test-esm-type-flag-errors.js @@ -1,4 +1,3 @@ -// Flags: --experimental-modules 'use strict'; const common = require('../common'); const assert = require('assert'); @@ -35,8 +34,6 @@ try { } function expect(opt = '', inputFile, want, wantsError = false) { - // TODO: Remove when --experimental-modules is unflagged - opt = `--experimental-modules ${opt}`; const argv = [inputFile]; const opts = { env: Object.assign({}, process.env, { NODE_OPTIONS: opt }), diff --git a/test/es-module/test-esm-type-flag.mjs b/test/es-module/test-esm-type-flag.mjs index 8358da5c765288..0be4194aeb9b4d 100644 --- a/test/es-module/test-esm-type-flag.mjs +++ b/test/es-module/test-esm-type-flag.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import cjs from '../fixtures/baz.js'; import { message } from '../fixtures/es-modules/message.mjs'; diff --git a/test/es-module/test-esm-unknown-or-no-extension.js b/test/es-module/test-esm-unknown-or-no-extension.js index c1cafbe8886413..3b1802a4dcedbd 100644 --- a/test/es-module/test-esm-unknown-or-no-extension.js +++ b/test/es-module/test-esm-unknown-or-no-extension.js @@ -16,7 +16,7 @@ const assert = require('assert'); '/es-modules/package-type-module/imports-unknownext.mjs', ].forEach((fixturePath) => { const entry = fixtures.path(fixturePath); - const child = spawn(process.execPath, ['--experimental-modules', entry]); + const child = spawn(process.execPath, [entry]); let stdout = ''; let stderr = ''; child.stderr.setEncoding('utf8'); diff --git a/test/es-module/test-esm-wasm.mjs b/test/es-module/test-esm-wasm.mjs index 4a9180199c95e7..b2218ce2f09893 100644 --- a/test/es-module/test-esm-wasm.mjs +++ b/test/es-module/test-esm-wasm.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-wasm-modules +// Flags: --experimental-wasm-modules import '../common/index.mjs'; import { path } from '../common/fixtures.mjs'; import { add, addImported } from '../fixtures/es-modules/simple.wasm'; @@ -18,7 +18,6 @@ strictEqual(addImported(1), 43); // Test warning message const child = spawn(process.execPath, [ - '--experimental-modules', '--experimental-wasm-modules', path('/es-modules/wasm-modules.mjs') ]); diff --git a/test/es-module/test-esm-windows.js b/test/es-module/test-esm-windows.js index 44af65d6a4e031..76e016217b3ef8 100644 --- a/test/es-module/test-esm-windows.js +++ b/test/es-module/test-esm-windows.js @@ -1,6 +1,5 @@ 'use strict'; -// Flags: --experimental-modules // This test ensures that JavaScript file that includes // a reserved Windows word can be loaded as ESM module diff --git a/test/message/async_error_eval_esm.js b/test/message/async_error_eval_esm.js index 33675b5a9db286..0c9b7378d54729 100644 --- a/test/message/async_error_eval_esm.js +++ b/test/message/async_error_eval_esm.js @@ -26,7 +26,6 @@ main(); // --eval ESM { const child = spawnSync(process.execPath, [ - '--experimental-modules', '--input-type', 'module', '-e', diff --git a/test/message/async_error_eval_esm.out b/test/message/async_error_eval_esm.out index 578a9f5c26160e..769fac7a0d408e 100644 --- a/test/message/async_error_eval_esm.out +++ b/test/message/async_error_eval_esm.out @@ -1,7 +1,6 @@ Error: test at one (file:*/[eval1]:2:9) at two (file:*/[eval1]:15:9) - at processTicksAndRejections (internal/process/task_queues.js:*:*) at async three (file:*/[eval1]:18:3) at async four (file:*/[eval1]:22:3) at async main (file:*/[eval1]:28:5) diff --git a/test/message/async_error_sync_esm.mjs b/test/message/async_error_sync_esm.mjs index f16256d7778b81..fdb6a260d1284b 100644 --- a/test/message/async_error_sync_esm.mjs +++ b/test/message/async_error_sync_esm.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import four from '../fixtures/async-error.js'; diff --git a/test/message/async_error_sync_esm.out b/test/message/async_error_sync_esm.out index f34628ef44e52a..6577fff6944723 100644 --- a/test/message/async_error_sync_esm.out +++ b/test/message/async_error_sync_esm.out @@ -4,4 +4,4 @@ Error: test at two (*fixtures*async-error.js:17:9) at async three (*fixtures*async-error.js:20:3) at async four (*fixtures*async-error.js:24:3) - at async main (*message*async_error_sync_esm.mjs:7:5) + at async main (*message*async_error_sync_esm.mjs:6:5) diff --git a/test/message/esm_display_syntax_error.mjs b/test/message/esm_display_syntax_error.mjs index 829186725554bf..bda4a7e6ebe3a3 100644 --- a/test/message/esm_display_syntax_error.mjs +++ b/test/message/esm_display_syntax_error.mjs @@ -1,3 +1,2 @@ -// Flags: --experimental-modules 'use strict'; await async () => 0; diff --git a/test/message/esm_display_syntax_error.out b/test/message/esm_display_syntax_error.out index 5e82a1e1ee8f87..778d901129fa95 100644 --- a/test/message/esm_display_syntax_error.out +++ b/test/message/esm_display_syntax_error.out @@ -1,5 +1,5 @@ (node:*) ExperimentalWarning: The ESM module loader is experimental. -file:///*/test/message/esm_display_syntax_error.mjs:3 +file:///*/test/message/esm_display_syntax_error.mjs:2 await async () => 0; ^^^^^ diff --git a/test/message/esm_display_syntax_error_import.mjs b/test/message/esm_display_syntax_error_import.mjs index 4c41b292efd4d6..2173cb2b2e3a71 100644 --- a/test/message/esm_display_syntax_error_import.mjs +++ b/test/message/esm_display_syntax_error_import.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules /* eslint-disable no-unused-vars */ import '../common/index.mjs'; import { diff --git a/test/message/esm_display_syntax_error_import.out b/test/message/esm_display_syntax_error_import.out index a3601d6cb46fab..e39744a049b59b 100644 --- a/test/message/esm_display_syntax_error_import.out +++ b/test/message/esm_display_syntax_error_import.out @@ -1,5 +1,5 @@ (node:*) ExperimentalWarning: The ESM module loader is experimental. -file:///*/test/message/esm_display_syntax_error_import.mjs:6 +file:///*/test/message/esm_display_syntax_error_import.mjs:5 notfound ^^^^^^^^ SyntaxError: The requested module '../fixtures/es-module-loaders/module-named-exports.mjs' does not provide an export named 'notfound' diff --git a/test/message/esm_display_syntax_error_import_module.mjs b/test/message/esm_display_syntax_error_import_module.mjs index 346b3489fd920d..c0345c44fb3fda 100644 --- a/test/message/esm_display_syntax_error_import_module.mjs +++ b/test/message/esm_display_syntax_error_import_module.mjs @@ -1,3 +1,2 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import '../fixtures/es-module-loaders/syntax-error-import.mjs'; diff --git a/test/message/esm_display_syntax_error_module.mjs b/test/message/esm_display_syntax_error_module.mjs index 1f2b87ecd0cb1a..da40a4ead8d3c1 100644 --- a/test/message/esm_display_syntax_error_module.mjs +++ b/test/message/esm_display_syntax_error_module.mjs @@ -1,3 +1,2 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import '../fixtures/es-module-loaders/syntax-error.mjs'; diff --git a/test/message/esm_loader_not_found.mjs b/test/message/esm_loader_not_found.mjs index fd6f29ac531507..2b47e5a03ec9e6 100644 --- a/test/message/esm_loader_not_found.mjs +++ b/test/message/esm_loader_not_found.mjs @@ -1,3 +1,3 @@ -// Flags: --experimental-modules --experimental-loader i-dont-exist +// Flags: --experimental-loader i-dont-exist import '../common/index.mjs'; console.log('This should not be printed'); diff --git a/test/message/esm_loader_syntax_error.mjs b/test/message/esm_loader_syntax_error.mjs index 7caad4056e08d2..68cde42e585644 100644 --- a/test/message/esm_loader_syntax_error.mjs +++ b/test/message/esm_loader_syntax_error.mjs @@ -1,3 +1,3 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/syntax-error.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/syntax-error.mjs import '../common/index.mjs'; console.log('This should not be printed'); diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index 391fdad4d35cf4..e07ca03e807b5d 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -50,6 +50,16 @@ const expectedModules = new Set([ 'NativeModule internal/modules/run_main', 'NativeModule internal/modules/cjs/helpers', 'NativeModule internal/modules/cjs/loader', + 'NativeModule internal/modules/esm/create_dynamic_module', + 'NativeModule internal/modules/esm/get_format', + 'NativeModule internal/modules/esm/get_source', + 'NativeModule internal/modules/esm/loader', + 'NativeModule internal/modules/esm/module_job', + 'NativeModule internal/modules/esm/module_map', + 'NativeModule internal/modules/esm/resolve', + 'NativeModule internal/modules/esm/transform_source', + 'NativeModule internal/modules/esm/translators', + 'NativeModule internal/process/esm_loader', 'NativeModule internal/options', 'NativeModule internal/priority_queue', 'NativeModule internal/process/execution', @@ -68,6 +78,7 @@ const expectedModules = new Set([ 'NativeModule internal/util/inspect', 'NativeModule internal/util/types', 'NativeModule internal/validators', + 'NativeModule internal/vm/module', 'NativeModule path', 'NativeModule timers', 'NativeModule url', diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 71482205932a27..be063b79fad320 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -234,7 +234,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`, // Assert that "42\n" is written to stdout on module eval. -const execOptions = '--experimental-modules --input-type module'; +const execOptions = '--input-type module'; child.exec( `${nodejs} ${execOptions} --eval "console.log(42)"`, common.mustCall((err, stdout) => { diff --git a/test/parallel/test-cli-syntax-piped-bad.js b/test/parallel/test-cli-syntax-piped-bad.js index 5da5f07e57d0ad..abd924848fc417 100644 --- a/test/parallel/test-cli-syntax-piped-bad.js +++ b/test/parallel/test-cli-syntax-piped-bad.js @@ -39,7 +39,7 @@ syntaxArgs.forEach(function(arg) { const stdin = 'export var p = 5; var foo bar;'; const c = spawnSync( node, - ['--experimental-modules', '--input-type=module', '--no-warnings', arg], + ['--input-type=module', '--no-warnings', arg], { encoding: 'utf8', input: stdin } ); diff --git a/test/parallel/test-cli-syntax-piped-good.js b/test/parallel/test-cli-syntax-piped-good.js index 5df5eb1c51d105..43de5d32f40d40 100644 --- a/test/parallel/test-cli-syntax-piped-good.js +++ b/test/parallel/test-cli-syntax-piped-good.js @@ -30,7 +30,7 @@ syntaxArgs.forEach(function(arg) { const stdin = 'export var p = 5; throw new Error("should not get run");'; const c = spawnSync( node, - ['--experimental-modules', '--no-warnings', '--input-type=module', arg], + ['--no-warnings', '--input-type=module', arg], { encoding: 'utf8', input: stdin } ); diff --git a/test/parallel/test-dns-lookupService.js b/test/parallel/test-dns-lookupService.js index f78e98766063f7..dc04893c28f9fd 100644 --- a/test/parallel/test-dns-lookupService.js +++ b/test/parallel/test-dns-lookupService.js @@ -5,11 +5,17 @@ const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); const cares = internalBinding('cares_wrap'); const { UV_ENOENT } = internalBinding('uv'); -const dns = require('dns'); // Stub `getnameinfo` to *always* error. cares.getnameinfo = () => UV_ENOENT; +// Because dns promises is attached lazily, +// and turn accesses getnameinfo on init +// but this lazy access is triggered by ES named +// instead of lazily itself, we must require +// dns after hooking cares +const dns = require('dns'); + assert.throws( () => dns.lookupService('127.0.0.1', 80, common.mustNotCall()), { diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js index 19d493c519b5e3..707fa7bb56f9e5 100644 --- a/test/parallel/test-inspector-esm.js +++ b/test/parallel/test-inspector-esm.js @@ -99,8 +99,8 @@ async function testBreakpoint(session) { } async function runTest() { - const child = new NodeInstance(['--inspect-brk=0', '--experimental-modules'], - '', fixtures.path('es-modules/loop.mjs')); + const child = new NodeInstance(['--inspect-brk=0'], '', + fixtures.path('es-modules/loop.mjs')); const session = await child.connectInspectorSession(); await testBreakpointOnStart(session); diff --git a/test/parallel/test-loaders-unknown-builtin-module.mjs b/test/parallel/test-loaders-unknown-builtin-module.mjs index b0b1d400e6904e..464dbeb22a9b31 100644 --- a/test/parallel/test-loaders-unknown-builtin-module.mjs +++ b/test/parallel/test-loaders-unknown-builtin-module.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs +// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs import { expectsError, mustCall } from '../common/index.mjs'; import assert from 'assert'; diff --git a/test/parallel/test-module-main-extension-lookup.js b/test/parallel/test-module-main-extension-lookup.js index 9e7eab295e8795..58d78e09b1199e 100644 --- a/test/parallel/test-module-main-extension-lookup.js +++ b/test/parallel/test-module-main-extension-lookup.js @@ -5,7 +5,5 @@ const { execFileSync } = require('child_process'); const node = process.argv[0]; -execFileSync(node, ['--experimental-modules', - fixtures.path('es-modules', 'test-esm-ok.mjs')]); -execFileSync(node, ['--experimental-modules', - fixtures.path('es-modules', 'noext')]); +execFileSync(node, [fixtures.path('es-modules', 'test-esm-ok.mjs')]); +execFileSync(node, [fixtures.path('es-modules', 'noext')]); diff --git a/test/parallel/test-module-main-fail.js b/test/parallel/test-module-main-fail.js index a6457f33b659dd..c66b6f2f7a843f 100644 --- a/test/parallel/test-module-main-fail.js +++ b/test/parallel/test-module-main-fail.js @@ -4,18 +4,15 @@ const assert = require('assert'); const { execFileSync } = require('child_process'); const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs']; -const flags = [[], ['--experimental-modules']]; const node = process.argv[0]; -for (const args of flags) { - for (const entryPoint of entryPoints) { - try { - execFileSync(node, args.concat(entryPoint), { stdio: 'pipe' }); - } catch (e) { - assert(e.toString().match(/Error: Cannot find module/)); - continue; - } - assert.fail('Executing node with inexistent entry point should ' + - `fail. Entry point: ${entryPoint}, Flags: [${args}]`); +for (const entryPoint of entryPoints) { + try { + execFileSync(node, [entryPoint], { stdio: 'pipe' }); + } catch (e) { + assert(e.toString().match(/Error: Cannot find module/)); + continue; } + assert.fail('Executing node with inexistent entry point should ' + + `fail. Entry point: ${entryPoint}`); } diff --git a/test/parallel/test-module-main-preserve-symlinks-fail.js b/test/parallel/test-module-main-preserve-symlinks-fail.js index b46497b625261f..bbaf451c3ce539 100644 --- a/test/parallel/test-module-main-preserve-symlinks-fail.js +++ b/test/parallel/test-module-main-preserve-symlinks-fail.js @@ -4,7 +4,7 @@ const assert = require('assert'); const { execFileSync } = require('child_process'); const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs']; -const flags = [[], ['--experimental-modules', '--preserve-symlinks']]; +const flags = [[], ['--preserve-symlinks']]; const node = process.argv[0]; for (const args of flags) { diff --git a/test/parallel/test-repl-import-referrer.js b/test/parallel/test-repl-import-referrer.js index 400015ced07f59..19b3fe721b5c43 100644 --- a/test/parallel/test-repl-import-referrer.js +++ b/test/parallel/test-repl-import-referrer.js @@ -4,11 +4,7 @@ const assert = require('assert'); const cp = require('child_process'); const fixtures = require('../common/fixtures'); -const args = [ - '--interactive', - '--experimental-repl-await', - '--experimental-modules' -]; +const args = ['--interactive', '--experimental-repl-await']; const opts = { cwd: fixtures.path('es-modules') }; const child = cp.spawn(process.execPath, args, opts); diff --git a/test/parallel/test-source-map-enable.js b/test/parallel/test-source-map-enable.js index ec2241f985281d..71130441438dcc 100644 --- a/test/parallel/test-source-map-enable.js +++ b/test/parallel/test-source-map-enable.js @@ -66,7 +66,6 @@ function nextdir() { const coverageDirectory = nextdir(); const output = spawnSync(process.execPath, [ '--no-warnings', - '--experimental-modules', require.resolve('../fixtures/source-map/esm-basic.mjs') ], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } }); assert.strictEqual(output.stderr.toString(), ''); @@ -217,7 +216,6 @@ function nextdir() { { const output = spawnSync(process.execPath, [ '--enable-source-maps', - '--experimental-modules', require.resolve('../fixtures/source-map/babel-esm.mjs') ]); assert.ok( diff --git a/test/parallel/test-vm-module-dynamic-import.js b/test/parallel/test-vm-module-dynamic-import.js index 897d9f27d73376..70229b3897874b 100644 --- a/test/parallel/test-vm-module-dynamic-import.js +++ b/test/parallel/test-vm-module-dynamic-import.js @@ -1,6 +1,6 @@ 'use strict'; -// Flags: --experimental-vm-modules --experimental-modules +// Flags: --experimental-vm-modules const common = require('../common'); diff --git a/test/parallel/test-worker-esm-exit.js b/test/parallel/test-worker-esm-exit.js index aebb17edda0baf..8c38faf3b72f8d 100644 --- a/test/parallel/test-worker-esm-exit.js +++ b/test/parallel/test-worker-esm-exit.js @@ -4,8 +4,7 @@ const fixtures = require('../common/fixtures'); const assert = require('assert'); const { Worker } = require('worker_threads'); -const w = new Worker(fixtures.path('es-modules/import-process-exit.mjs'), - { execArgv: ['--experimental-modules'] }); +const w = new Worker(fixtures.path('es-modules/import-process-exit.mjs')); w.on('error', common.mustNotCall()); w.on('exit', common.mustCall((code) => assert.strictEqual(code, 42)) diff --git a/test/parallel/test-worker-esm-missing-main.js b/test/parallel/test-worker-esm-missing-main.js index 8f4cfb0fe7fa9b..07bfb6a0276cd5 100644 --- a/test/parallel/test-worker-esm-missing-main.js +++ b/test/parallel/test-worker-esm-missing-main.js @@ -8,7 +8,7 @@ const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const missing = path.join(tmpdir.path, 'does-not-exist.js'); -const worker = new Worker(missing, { execArgv: ['--experimental-modules'] }); +const worker = new Worker(missing); worker.on('error', common.mustCall((err) => { // eslint-disable-next-line node-core/no-unescaped-regexp-dot diff --git a/test/parallel/test-worker-esmodule.js b/test/parallel/test-worker-esmodule.js index 33788c1422ce84..e7f9bd7aea6c8a 100644 --- a/test/parallel/test-worker-esmodule.js +++ b/test/parallel/test-worker-esmodule.js @@ -1,4 +1,3 @@ -// Flags: --experimental-modules 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); diff --git a/test/parallel/test-worker-mjs-workerdata.js b/test/parallel/test-worker-mjs-workerdata.js index c107730ea4bba2..b0a65e2e805c1e 100644 --- a/test/parallel/test-worker-mjs-workerdata.js +++ b/test/parallel/test-worker-mjs-workerdata.js @@ -7,8 +7,7 @@ const { Worker } = require('worker_threads'); const workerData = 'Hello from main thread'; const worker = new Worker(fixtures.path('worker-data.mjs'), { - workerData, - execArgv: ['--experimental-modules'] + workerData }); worker.on('message', common.mustCall((message) => { diff --git a/test/parallel/test-worker-unsupported-eval-on-url.mjs b/test/parallel/test-worker-unsupported-eval-on-url.mjs index f58f0d09789b82..c3d2050ec5f2da 100644 --- a/test/parallel/test-worker-unsupported-eval-on-url.mjs +++ b/test/parallel/test-worker-unsupported-eval-on-url.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import '../common/index.mjs'; import assert from 'assert'; import { Worker } from 'worker_threads'; diff --git a/test/parallel/test-worker.mjs b/test/parallel/test-worker.mjs index 51cd27a21cf00c..4ee3f7dc96fa4c 100644 --- a/test/parallel/test-worker.mjs +++ b/test/parallel/test-worker.mjs @@ -1,4 +1,3 @@ -// Flags: --experimental-modules import { mustCall } from '../common/index.mjs'; import assert from 'assert'; import { Worker, isMainThread, parentPort } from 'worker_threads';