summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2019-09-08 12:54:19 -0400
committerRich Trott <rtrott@gmail.com>2019-09-17 18:54:44 -0700
commit3f3ad38c878e2acdd36f724542c9aecd8b4474e9 (patch)
tree6f3eb07cbc035dea249fecd6320e7ad3a29e76b7 /test
parent17e420b23f5462db9f1951d98233fdaee889c721 (diff)
downloadandroid-node-v8-3f3ad38c878e2acdd36f724542c9aecd8b4474e9.tar.gz
android-node-v8-3f3ad38c878e2acdd36f724542c9aecd8b4474e9.tar.bz2
android-node-v8-3f3ad38c878e2acdd36f724542c9aecd8b4474e9.zip
module: reintroduce package exports dot main
This reintroduces the dot main in exports as discussed in the previous Node.js modules meeting. The implementation includes both CommonJS and ES module resolution with the associated documentation and resolver specification changes. In addition to the dot main, "exports" as a string or direct fallback array is supported as well. Co-Authored-By: Geoffrey Booth <GeoffreyBooth@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/29494 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/es-module/test-esm-exports.mjs14
1 files changed, 2 insertions, 12 deletions
diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs
index 4f77252158..5059a2d418 100644
--- a/test/es-module/test-esm-exports.mjs
+++ b/test/es-module/test-esm-exports.mjs
@@ -20,6 +20,8 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
// Fallbacks
['pkgexports/fallbackdir/asdf.js', { default: 'asdf' }],
['pkgexports/fallbackfile', { default: 'asdf' }],
+ // Dot main
+ ['pkgexports', { default: 'asdf' }],
]);
for (const [validSpecifier, expected] of validSpecifiers) {
if (validSpecifier === null) continue;
@@ -81,18 +83,6 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
}));
}
- // There's no main field so we won't find anything when importing the name.
- // The fact that "." is mapped is ignored, it's not a valid main config.
- loadFixture('pkgexports').catch(mustCall((err) => {
- if (isRequire) {
- strictEqual(err.code, 'MODULE_NOT_FOUND');
- assertStartsWith(err.message, 'Cannot find module \'pkgexports\'');
- } else {
- strictEqual(err.code, 'ERR_MODULE_NOT_FOUND');
- assertStartsWith(err.message, 'Cannot find main entry point');
- }
- }));
-
// Covering out bases - not a file is still not a file after dir mapping.
loadFixture('pkgexports/sub/not-a-file.js').catch(mustCall((err) => {
strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND');