mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:26:52 +00:00

This simplifies the top-level load when ES modules are enabled as we can entirely delegate the module resolver, which will hand over to CommonJS where appropriate. All not found errors are made consistent to throw during resolve and have the MODULE_NOT_FOUND code. Includes the test case from https://github.com/nodejs/node/pull/15736. Fixes: https://github.com/nodejs/node/issues/15732 PR-URL: https://github.com/nodejs/node/pull/16147 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
22 lines
680 B
JavaScript
22 lines
680 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const { execFileSync } = require('child_process');
|
|
|
|
const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs'];
|
|
const flags = [[], ['--experimental-modules', '--preserve-symlinks']];
|
|
const node = process.argv[0];
|
|
|
|
for (const args of flags) {
|
|
for (const entryPoint of entryPoints) {
|
|
try {
|
|
execFileSync(node, args.concat(entryPoint));
|
|
} 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}]`);
|
|
}
|
|
}
|