esm: unflag --experimental-modules

PR-URL: https://github.com/nodejs/node/pull/29866
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
Guy Bedford authored and Myles Borins committed 2019-11-17 00:39:55 -08:00
1 parent 26a9bdfca3
commit 3d8cdf191d
95 files changed
+194 -331

No files matched your search

+8 -8
View File
@@ -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`
<!-- YAML
@@ -342,9 +343,8 @@ Specify ICU data load path. (Overrides `NODE_ICU_DATA`.)
added: v12.0.0
-->
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
+15 -21
View File
@@ -27,12 +27,9 @@ specifier resolution, and default behavior.
<!-- type=misc -->
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!
```
+8 -8
View File
@@ -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
+2 -3
View File
@@ -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.
+8 -10
View File
@@ -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;
};
+9 -21
View File
@@ -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;
+12 -15
View File
@@ -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);
+2 -3
View File
@@ -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]);
+3 -8
View File
@@ -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;
}
+39 -49
View File
@@ -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'));
+3
View File
@@ -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;
+3 -7
View File
@@ -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);
+3 -28
View File
@@ -113,10 +113,6 @@ void PerIsolateOptions::CheckOptions(std::vector<std::string>* errors) {
}
void EnvironmentOptions::CheckOptions(std::vector<std::string>* 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<std::string>* 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,
-1
View File
@@ -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;
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
/* eslint-disable node-core/require-common-first, node-core/required-modules */
import { createRequire } from 'module';
+5 -3
View File
@@ -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);
}));
@@ -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';
@@ -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}`);
}));
+1 -7
View File
@@ -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');
}));
@@ -1,3 +1,2 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import('./test-esm-cyclic-dynamic-import.mjs');
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
'use strict';
const common = require('../common');
const assert = require('assert');
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import { strictEqual } from 'assert';
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
// Assert we can import files with `%` in their pathname.
@@ -1,5 +1,3 @@
// Flags: --experimental-modules
'use strict';
const common = require('../common');
const assert = require('assert');
@@ -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);
});
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
// ./test-esm-ok.mjs
-2
View File
@@ -1,5 +1,3 @@
// Flags: --experimental-modules
'use strict';
require('../common');
+1 -1
View File
@@ -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';
+1 -2
View File
@@ -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';
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
// eslint-disable-next-line no-undef
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -1,4 +1,4 @@
// Flags: --experimental-modules --experimental-json-modules
// Flags: --experimental-json-modules
import '../common/index.mjs';
import { strictEqual, deepStrictEqual } from 'assert';
+1 -1
View File
@@ -1,4 +1,4 @@
// Flags: --experimental-modules --experimental-json-modules
// Flags: --experimental-json-modules
import '../common/index.mjs';
import { strictEqual } from 'assert';
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
import { syncBuiltinESMExports } from 'module';
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
'use strict';
require('../common');
@@ -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';
@@ -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';
@@ -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';
@@ -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({
+1 -1
View File
@@ -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
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
+1 -1
View File
@@ -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';
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import * as fs from 'fs';
import assert from 'assert';
+1 -4
View File
@@ -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');
-2
View File
@@ -1,5 +1,3 @@
// Flags: --experimental-modules
import { mustCall } from '../common/index.mjs';
import { strictEqual } from 'assert';
@@ -53,5 +53,5 @@ function doTest(flags, done) {
// First test the commonjs module loader
doTest([], () => {
// Now test the new loader
doTest(['--experimental-modules'], () => {});
doTest([], () => {});
});
@@ -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';
@@ -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';
+1 -1
View File
@@ -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);
});
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
import process from 'process';
-1
View File
@@ -4,7 +4,6 @@ const assert = require('assert');
const { spawn } = require('child_process');
const child = spawn(process.execPath, [
'--experimental-modules',
'--interactive'
]);
child.stdin.end(`
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import { createRequire } from '../common/index.mjs';
import assert from 'assert';
//
+1 -1
View File
@@ -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';
@@ -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';
@@ -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';
-1
View File
@@ -1,5 +1,4 @@
#! }]) // isn't js
// Flags: --experimental-modules
import '../common/index.mjs';
const isJs = true;
-1
View File
@@ -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';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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);
});
+2 -2
View File
@@ -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 = {
+1 -1
View File
@@ -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);
});
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
@@ -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 }),
-1
View File
@@ -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';
+1 -1
View File
@@ -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';
-1
View File
@@ -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
-1
View File
@@ -26,7 +26,6 @@ main();
// --eval ESM
{
const child = spawnSync(process.execPath, [
'--experimental-modules',
'--input-type',
'module',
'-e',
-1
View File
@@ -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)
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import four from '../fixtures/async-error.js';
+1 -1
View File
@@ -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)
@@ -1,3 +1,2 @@
// Flags: --experimental-modules
'use strict';
await async () => 0;
+1 -1
View File
@@ -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;
^^^^^
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
/* eslint-disable no-unused-vars */
import '../common/index.mjs';
import {
@@ -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'
@@ -1,3 +1,2 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import '../fixtures/es-module-loaders/syntax-error-import.mjs';
@@ -1,3 +1,2 @@
// Flags: --experimental-modules
import '../common/index.mjs';
import '../fixtures/es-module-loaders/syntax-error.mjs';
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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');
+8
View File
@@ -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',
+1 -1
View File
@@ -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) => {
+1 -1
View File
@@ -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 }
);
+1 -1
View File
@@ -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 }
);
+7 -1
View File
@@ -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()),
{
+2 -2
View File
@@ -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);
@@ -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';
@@ -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')]);
+8 -11
View File
@@ -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}`);
}
@@ -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) {
-2
View File
@@ -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(
@@ -1,6 +1,6 @@
'use strict';
// Flags: --experimental-vm-modules --experimental-modules
// Flags: --experimental-vm-modules
const common = require('../common');
+1 -2
View File
@@ -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));
@@ -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
-1
View File
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
+1 -2
View File
@@ -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) => {