diff --git a/doc/api/cli.md b/doc/api/cli.md index d305644a0ff274..f415e246111640 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -161,8 +161,8 @@ Currently, overriding `Error.prepareStackTrace` is ignored when the added: v12.0.0 --> -To be used in conjunction with `--experimental-modules`. Sets the resolution -algorithm for resolving specifiers. Valid options are `explicit` and `node`. +Sets the resolution algorithm for resolving ES module specifiers. Valid options +are `explicit` and `node`. The default is `explicit`, which requires providing the full path to a module. The `node` mode will enable support for optional file extensions and @@ -191,7 +191,8 @@ Enable experimental JSON support for the ES Module loader. added: v8.5.0 --> -Enable experimental ES module support and caching modules. +Enable latest experimental modules features (currently +`--experimental-conditional-exports` and `--experimental-self-resolve`). ### `--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"`. @@ -409,7 +409,7 @@ endpoint on `http://host:port/json/list`. added: v9.0.0 --> -Specify the `module` of a custom [experimental ECMAScript Module][] loader. +Specify the `module` of a custom [experimental ECMAScript Module loader][]. `module` may be either a path to a file, or an ECMAScript Module name. ### `--max-http-header-size=size` @@ -1330,7 +1330,7 @@ greater than `4` (its current default value). For more information, see the [debugger]: debugger.html [debugging security implications]: https://nodejs.org/en/docs/guides/debugging-getting-started/#security-implications [emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor -[experimental ECMAScript Module]: esm.html#esm_resolve_hook +[experimental ECMAScript Module loader]: esm.html#esm_resolve_hook [libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html [remote code execution]: https://www.owasp.org/index.php/Code_Injection [context-aware]: addons.html#addons_context_aware_addons diff --git a/doc/api/esm.md b/doc/api/esm.md index f36470632b4763..bba2d0ee9cad75 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`. @@ -80,7 +77,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 @@ -114,9 +111,8 @@ 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 @@ -169,11 +165,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 @@ -927,8 +921,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 @@ -950,7 +944,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`. @@ -1061,7 +1055,7 @@ export async function resolve(specifier, With this loader, running: ```console -NODE_OPTIONS='--experimental-modules --experimental-loader ./custom-loader.mjs' node x.js +NODE_OPTIONS='--experimental-loader ./custom-loader.mjs' node x.js ``` would load the module `x.js` as an ES module with relative resolution support @@ -1352,11 +1346,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 --es-module-specifier-resolution=node index +$ node --es-module-specifier-resolution=node index success! ``` diff --git a/doc/api/vm.md b/doc/api/vm.md index f1b993996f3173..7712ea78abce0c 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -88,8 +88,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 @@ -854,8 +854,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 @@ -951,8 +951,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 @@ -1028,8 +1028,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 99ff358df9c419..7c4cb61a952b94 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -120,7 +120,7 @@ Enable experimental support for "require" and "node" conditional export targets. Enable experimental JSON interop support for the ES Module loader. . .It Fl -experimental-modules -Enable experimental ES module support and caching modules. +Enable experimental latest experimental modules features. . .It Fl -experimental-resolve-self Enable experimental support for a package to load itself. @@ -208,8 +208,7 @@ It uses the Chrome DevTools Protocol. .It Fl -experimental-loader Ns = Ns Ar module Specify the .Ar module -as a custom loader, to load -.Fl -experimental-modules . +to use as a custom module loader. . .It Fl -max-http-header-size Ns = Ns Ar size Specify the maximum size of HTTP headers in bytes. Defaults to 8KB. diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 48afed2556a51b..1915dc667461e3 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -211,23 +211,21 @@ function requireWithFallbackInDeps(request) { } // This is exposed for public loaders -NativeModule.prototype.compileForPublicLoader = function(needToSyncExports) { +NativeModule.prototype.compileForPublicLoader = function() { 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.compile(); - 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 ? [] : Object.keys(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 ? [] : Object.keys(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 39bc128bf7bf13..793ee1814200e0 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -401,24 +401,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() { @@ -460,9 +451,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/main/check_syntax.js b/lib/internal/main/check_syntax.js index a3aba9a00fb5e2..c5d919bd15bfab 100644 --- a/lib/internal/main/check_syntax.js +++ b/lib/internal/main/check_syntax.js @@ -47,21 +47,18 @@ 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 resolve = require('internal/modules/esm/default_resolve'); - const { format } = resolve(pathToFileURL(filename).toString()); - 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 resolve = require('internal/modules/esm/default_resolve'); + const { format } = resolve(pathToFileURL(filename).toString()); + 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 77d997b97a1c7a..eae9042041a1a7 100644 --- a/lib/internal/main/run_main_module.js +++ b/lib/internal/main/run_main_module.js @@ -10,7 +10,6 @@ const CJSModule = require('internal/modules/cjs/loader').Module; 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 +// Note: this loads the module through the ESM loader if the module is +// determined to be an ES module CJSModule.runMain(process.argv[1]); diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index 7a9870024515ed..b75f67c0a4ddad 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -6,8 +6,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'); @@ -16,11 +14,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; } } @@ -45,10 +43,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 3aee3399b8e904..cb68471b5c753f 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -57,7 +57,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 experimentalSelf = getOptionValue('--experimental-resolve-self'); const experimentalConditionalExports = getOptionValue('--experimental-conditional-exports'); @@ -65,7 +64,6 @@ const manifest = getOptionValue('--experimental-policy') ? require('internal/process/policy').manifest : null; const { compileFunction } = internalBinding('contextify'); - const { ERR_INVALID_ARG_VALUE, ERR_INVALID_OPT_VALUE, @@ -479,7 +477,7 @@ function applyExports(basePath, expansion) { const mappingKey = `.${expansion}`; let pkgExports = readPackageExports(basePath); - if (pkgExports === undefined || pkgExports === null || !experimentalModules) + if (pkgExports === undefined || pkgExports === null) return path.resolve(basePath, mappingKey); if (isConditionalDotExportSugar(pkgExports, basePath)) @@ -855,7 +853,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. @@ -979,31 +977,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 */) + ); } }; @@ -1037,10 +1033,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, + }, }); } let compiled; @@ -1063,20 +1059,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; } @@ -1159,9 +1153,7 @@ Module._extensions['.js'] = function(module, filename) { ); warnRequireESM = false; } - if (experimentalModules) { - throw new ERR_REQUIRE_ESM(filename); - } + throw new ERR_REQUIRE_ESM(filename); } } const content = fs.readFileSync(filename, 'utf8'); @@ -1326,8 +1318,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/process/esm_loader.js b/lib/internal/process/esm_loader.js index 49463e284c541f..19099d9cbd58fd 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 88b0f5658489fc..21c0505b85f23d 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -283,11 +283,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; @@ -339,9 +335,9 @@ function REPLServer(prompt, script = vm.createScript(code, { filename: file, displayErrors: true, - importModuleDynamically: experimentalModules ? async (specifier) => { + importModuleDynamically: async (specifier) => { return asyncESM.ESMLoader.import(specifier, pwd); - } : undefined + } }); } catch (e) { debug('parse error %j', code, e); diff --git a/src/node_options.cc b/src/node_options.cc index 92ee79b583884b..85256a7e0a8e80 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -113,10 +113,6 @@ void PerIsolateOptions::CheckOptions(std::vector* errors) { } void EnvironmentOptions::CheckOptions(std::vector* errors) { - 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"); @@ -126,30 +122,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 (es_module_specifier_resolution != "node" && es_module_specifier_resolution != "explicit") { errors->push_back("invalid value for --es-module-specifier-resolution"); @@ -322,15 +300,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", - &EnvironmentOptions::experimental_modules, - kAllowedInEnvironment); + AddAlias("--experimental-modules", { "--experimental-conditional-exports", + "--experimental-resolve-self" }); AddOption("--experimental-conditional-exports", "experimental support for conditional exports targets", &EnvironmentOptions::experimental_conditional_exports, diff --git a/src/node_options.h b/src/node_options.h index af69d67ce073ee..c36c0ad160c30f 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -103,7 +103,6 @@ class EnvironmentOptions : public Options { bool enable_source_maps = false; bool experimental_conditional_exports = false; bool experimental_json_modules = false; - bool experimental_modules = false; bool experimental_resolve_self = false; std::string es_module_specifier_resolution; bool experimental_wasm_modules = false; diff --git a/test/common/index.mjs b/test/common/index.mjs index f747ee327913a5..5ad6ec3c11eadc 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-cjs-esm-warn.js b/test/es-module/test-cjs-esm-warn.js index ec368c73e2ef2d..b1b2e7f434256f 100644 --- a/test/es-module/test-cjs-esm-warn.js +++ b/test/es-module/test-cjs-esm-warn.js @@ -23,10 +23,10 @@ child.stderr.on('data', (data) => { stderr += data; }); child.on('close', common.mustCall((code, signal) => { - assert.strictEqual(code, 0); + assert.strictEqual(code, 1); assert.strictEqual(signal, null); - assert.strictEqual(stderr, `(node:${child.pid}) Warning: ` + + assert.ok(stderr.startsWith(`(node:${child.pid}) Warning: ` + 'require() of ES modules is not supported.\nrequire() of ' + `${required} from ${requiring} ` + 'is an ES module file as it is a .js file whose nearest parent ' + @@ -34,5 +34,7 @@ child.on('close', common.mustCall((code, signal) => { 'files in that package scope as ES modules.\nInstead rename ' + `${basename} to end in .cjs, change the requiring code to use ` + 'import(), or remove "type": "module" from ' + - `${pjson}.\n`); + `${pjson}.\n`)); + assert.ok(stderr.indexOf( + 'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module') !== -1); })); 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 bc781b0363cc44..f2f166b47ee3d8 100644 --- a/test/es-module/test-esm-data-urls.js +++ b/test/es-module/test-esm-data-urls.js @@ -1,4 +1,3 @@ -// Flags: --experimental-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 ca9c99007b5b1b..8a92ac41edbdfd 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 2683b5df68e9fa..a361bafaa83804 100644 --- a/test/es-module/test-esm-exports.mjs +++ b/test/es-module/test-esm-exports.mjs @@ -1,5 +1,4 @@ -// Flags: --experimental-modules --experimental-resolve-self --experimental-conditional-exports - +// Flags: --experimental-modules import { mustCall } from '../common/index.mjs'; import { ok, deepStrictEqual, strictEqual } from 'assert'; 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-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 9e676e57d1b90f..cdf9476b29f864 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 3d246124a9bdae..9dd33f26b557d1 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 { strictEqual } from 'assert'; 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-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-invalid-format.mjs b/test/es-module/test-esm-loader-invalid-format.mjs index 9e26d646d479a1..75f5de83805394 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 f42900c58e049c..4007be052dd7c7 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 70f5a1015907a2..5493c6c47c9643 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-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-no-extension.js b/test/es-module/test-esm-no-extension.js index 81b8e5b4327ad0..392bb5638b0e34 100644 --- a/test/es-module/test-esm-no-extension.js +++ b/test/es-module/test-esm-no-extension.js @@ -10,10 +10,7 @@ const entry = fixtures.path('/es-modules/package-type-module/noext-esm'); // Run a module that does not have extension. // This is to ensure that "type": "module" applies to extensionless files. -const child = spawn(process.execPath, [ - '--experimental-modules', - entry -]); +const child = spawn(process.execPath, [entry]); let stdout = ''; child.stdout.setEncoding('utf8'); 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.mjs b/test/es-module/test-esm-specifiers.mjs index 59d54cbf63dc79..3e7bc181962f4f 100644 --- a/test/es-module/test-esm-specifiers.mjs +++ b/test/es-module/test-esm-specifiers.mjs @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --es-module-specifier-resolution=node +// Flags: --es-module-specifier-resolution=node import { mustNotCall } from '../common/index.mjs'; import assert from 'assert'; 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-type-flag-errors.js b/test/es-module/test-esm-type-flag-errors.js index 8725fb62323b75..5d19cedd84a844 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'); @@ -32,8 +31,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-wasm.mjs b/test/es-module/test-esm-wasm.mjs index bcfce797a9cc8b..46df5994afa932 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 { add, addImported } from '../fixtures/es-modules/simple.wasm'; import { state } from '../fixtures/es-modules/wasm-dep.mjs'; diff --git a/test/es-module/test-esm-windows.js b/test/es-module/test-esm-windows.js index 64ba1249a76c06..c4d9ff4cde2c95 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 c963630f5d32ab..40d37c3b8fc831 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -48,6 +48,13 @@ const expectedModules = new Set([ 'NativeModule internal/linkedlist', 'NativeModule internal/modules/cjs/helpers', 'NativeModule internal/modules/cjs/loader', + 'NativeModule internal/modules/esm/create_dynamic_module', + 'NativeModule internal/modules/esm/default_resolve', + 'NativeModule internal/modules/esm/loader', + 'NativeModule internal/modules/esm/module_job', + 'NativeModule internal/modules/esm/module_map', + 'NativeModule internal/modules/esm/translators', + 'NativeModule internal/process/esm_loader', 'NativeModule internal/options', 'NativeModule internal/priority_queue', 'NativeModule internal/process/execution', @@ -64,6 +71,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 0d2ea48c06fa39..2cece62a437d52 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 b5f55b68d717ff..f0848d29423d9e 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-source-map.js b/test/parallel/test-source-map.js index 13fa391aafefcc..c14892890cb195 100644 --- a/test/parallel/test-source-map.js +++ b/test/parallel/test-source-map.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 c0b9d874895725..184106936536db 100644 --- a/test/parallel/test-worker-esm-exit.js +++ b/test/parallel/test-worker-esm-exit.js @@ -4,7 +4,6 @@ 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', (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) => {