From ee953d813be1fb19930e0e64196c0aa33699b133 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Wed, 27 Nov 2019 01:54:23 -0500 Subject: 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 Reviewed-By: Guy Bedford --- test/es-module/test-esm-specifiers-both-flags.mjs | 16 ++++++++++++++++ test/es-module/test-esm-specifiers-legacy-flag.mjs | 18 ++++++++++++++++++ test/es-module/test-esm-specifiers.mjs | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/es-module/test-esm-specifiers-both-flags.mjs create mode 100644 test/es-module/test-esm-specifiers-legacy-flag.mjs (limited to 'test/es-module') 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'; -- cgit v1.2.3