summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMyles Borins <mylesborins@google.com>2019-11-27 01:54:23 -0500
committerMyles Borins <mylesborins@google.com>2019-12-04 13:21:41 -0800
commitee953d813be1fb19930e0e64196c0aa33699b133 (patch)
tree2b11d0315bcbb33ee26ad333a798ff012da696fa /test
parent12254ce242c30d403b523ad9adb60a0280080957 (diff)
downloadandroid-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.tar.gz
android-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.tar.bz2
android-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.zip
esm: make specifier flag clearly experimental
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: https://github.com/nodejs/node/pull/30678 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/es-module/test-esm-specifiers-both-flags.mjs16
-rw-r--r--test/es-module/test-esm-specifiers-legacy-flag.mjs18
-rw-r--r--test/es-module/test-esm-specifiers.mjs2
-rw-r--r--test/parallel/test-process-env-allowed-flags-are-documented.js1
4 files changed, 36 insertions, 1 deletions
diff --git a/test/es-module/test-esm-specifiers-both-flags.mjs b/test/es-module/test-esm-specifiers-both-flags.mjs
new file mode 100644
index 0000000000..fc5c7fcd0e
--- /dev/null
+++ b/test/es-module/test-esm-specifiers-both-flags.mjs
@@ -0,0 +1,16 @@
+import { mustCall } from '../common/index.mjs';
+import { exec } from 'child_process';
+import assert from 'assert';
+
+const expectedError =
+ 'cannot use --es-module-specifier-resolution ' +
+ 'and --experimental-specifier-resolution at the same time';
+
+const flags = '--es-module-specifier-resolution=node ' +
+ '--experimental-specifier-resolution=node';
+
+exec(`${process.execPath} ${flags}`, {
+ timeout: 300
+}, mustCall((error) => {
+ assert(error.message.includes(expectedError));
+}));
diff --git a/test/es-module/test-esm-specifiers-legacy-flag.mjs b/test/es-module/test-esm-specifiers-legacy-flag.mjs
new file mode 100644
index 0000000000..fcf0c915b6
--- /dev/null
+++ b/test/es-module/test-esm-specifiers-legacy-flag.mjs
@@ -0,0 +1,18 @@
+// Flags: --es-module-specifier-resolution=node
+import '../common/index.mjs';
+import assert from 'assert';
+
+// commonJS index.js
+import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs';
+// esm index.js
+import module from '../fixtures/es-module-specifiers/package-type-module';
+// Notice the trailing slash
+import success, { explicit, implicit, implicitModule }
+ from '../fixtures/es-module-specifiers/';
+
+assert.strictEqual(commonjs, 'commonjs');
+assert.strictEqual(module, 'module');
+assert.strictEqual(success, 'success');
+assert.strictEqual(explicit, 'esm');
+assert.strictEqual(implicit, 'cjs');
+assert.strictEqual(implicitModule, 'cjs');
diff --git a/test/es-module/test-esm-specifiers.mjs b/test/es-module/test-esm-specifiers.mjs
index fdf9e5b25e..5e436f21b7 100644
--- a/test/es-module/test-esm-specifiers.mjs
+++ b/test/es-module/test-esm-specifiers.mjs
@@ -1,4 +1,4 @@
-// Flags: --es-module-specifier-resolution=node
+// Flags: --experimental-specifier-resolution=node
import { mustNotCall } from '../common/index.mjs';
import assert from 'assert';
import path from 'path';
diff --git a/test/parallel/test-process-env-allowed-flags-are-documented.js b/test/parallel/test-process-env-allowed-flags-are-documented.js
index 2e0d67eefc..f356f88fe9 100644
--- a/test/parallel/test-process-env-allowed-flags-are-documented.js
+++ b/test/parallel/test-process-env-allowed-flags-are-documented.js
@@ -85,6 +85,7 @@ const undocumented = difference(process.allowedNodeEnvironmentFlags,
documented);
// Remove intentionally undocumented options.
assert(undocumented.delete('--debug-arraybuffer-allocations'));
+assert(undocumented.delete('--es-module-specifier-resolution'));
assert(undocumented.delete('--experimental-worker'));
assert(undocumented.delete('--no-node-snapshot'));
assert(undocumented.delete('--loader'));