Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2021-06-09 13:51:41 +0300
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2021-06-13 17:22:34 +0300
commit4e17ffc793a2a484f376f8f696a2ea80eabb437d (patch)
treeeeda649008d3aecf224e455dd099dfb53f6c20fc /test
parent5b3587dbc64cc298701b62f8767d37976d57a451 (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')
-rw-r--r--test/es-module/test-esm-specifiers-legacy-flag.mjs3
-rw-r--r--test/fixtures/es-module-specifiers/dir-with-main/main.js1
-rw-r--r--test/fixtures/es-module-specifiers/dir-with-main/package.json3
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"
+}