0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/es-module/test-esm-main-lookup.mjs
Ben Noordhuis d7d6526260 tools: fix node-core/required-modules eslint rule
Make the node-core/required-modules eslint rule smart enough
to recognize that `import '../common/index.mjs'` in ESM files
imports the mandatory 'common' module.

PR-URL: https://github.com/nodejs/node/pull/27545
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-05-06 04:57:49 +02:00

26 lines
502 B
JavaScript

// Flags: --experimental-modules
import '../common/index.mjs';
import assert from 'assert';
async function main() {
let mod;
try {
mod = await import('../fixtures/es-modules/pjson-main');
} catch (e) {
assert.strictEqual(e.code, 'ERR_MODULE_NOT_FOUND');
}
assert.strictEqual(mod, undefined);
try {
mod = await import('../fixtures/es-modules/pjson-main/main.mjs');
} catch (e) {
console.log(e);
assert.fail();
}
assert.strictEqual(mod.main, 'main');
}
main();