diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2021-06-09 13:51:41 +0300 |
---|---|---|
committer | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2021-06-13 17:22:34 +0300 |
commit | 4e17ffc793a2a484f376f8f696a2ea80eabb437d (patch) | |
tree | eeda649008d3aecf224e455dd099dfb53f6c20fc /test | |
parent | 5b3587dbc64cc298701b62f8767d37976d57a451 (diff) |
module: fix legacy `node` specifier resolution to resolve `"main"` field
PR-URL: https://github.com/nodejs/node/pull/38979
Fixes: https://github.com/nodejs/node/issues/32103
Fixes: https://github.com/nodejs/node/issues/38739
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'test')
3 files changed, 7 insertions, 0 deletions
diff --git a/test/es-module/test-esm-specifiers-legacy-flag.mjs b/test/es-module/test-esm-specifiers-legacy-flag.mjs index fcf0c915b64..5351846c6a8 100644 --- a/test/es-module/test-esm-specifiers-legacy-flag.mjs +++ b/test/es-module/test-esm-specifiers-legacy-flag.mjs @@ -6,12 +6,15 @@ import assert from 'assert'; import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs'; // esm index.js import module from '../fixtures/es-module-specifiers/package-type-module'; +// Directory entry with main.js +import main from '../fixtures/es-module-specifiers/dir-with-main'; // Notice the trailing slash import success, { explicit, implicit, implicitModule } from '../fixtures/es-module-specifiers/'; assert.strictEqual(commonjs, 'commonjs'); assert.strictEqual(module, 'module'); +assert.strictEqual(main, 'main'); assert.strictEqual(success, 'success'); assert.strictEqual(explicit, 'esm'); assert.strictEqual(implicit, 'cjs'); diff --git a/test/fixtures/es-module-specifiers/dir-with-main/main.js b/test/fixtures/es-module-specifiers/dir-with-main/main.js new file mode 100644 index 00000000000..dfdd47b8773 --- /dev/null +++ b/test/fixtures/es-module-specifiers/dir-with-main/main.js @@ -0,0 +1 @@ +module.exports = 'main'; diff --git a/test/fixtures/es-module-specifiers/dir-with-main/package.json b/test/fixtures/es-module-specifiers/dir-with-main/package.json new file mode 100644 index 00000000000..2a4fe363081 --- /dev/null +++ b/test/fixtures/es-module-specifiers/dir-with-main/package.json @@ -0,0 +1,3 @@ +{ + "main": "./main.js" +} |