From 3f3ad38c878e2acdd36f724542c9aecd8b4474e9 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 8 Sep 2019 12:54:19 -0400 Subject: 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 PR-URL: https://github.com/nodejs/node/pull/29494 Reviewed-By: Jan Krems Reviewed-By: Myles Borins --- test/es-module/test-esm-exports.mjs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'test') 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'); -- cgit v1.2.3