summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/internal/modules/esm/default_resolve.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js
index 169c6f3569..c9ef3883c4 100644
--- a/lib/internal/modules/esm/default_resolve.js
+++ b/lib/internal/modules/esm/default_resolve.js
@@ -13,8 +13,8 @@ const { getOptionValue } = require('internal/options');
const preserveSymlinks = getOptionValue('--preserve-symlinks');
const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
const experimentalJsonModules = getOptionValue('--experimental-json-modules');
-const esModuleSpecifierResolution =
- getOptionValue('--es-module-specifier-resolution');
+const experimentalSpeciferResolution =
+ getOptionValue('--experimental-specifier-resolution');
const typeFlag = getOptionValue('--input-type');
const experimentalWasmModules = getOptionValue('--experimental-wasm-modules');
const { resolve: moduleWrapResolve,
@@ -110,10 +110,14 @@ function resolve(specifier, parentURL) {
if (ext === '.js' || (!format && isMain))
format = getPackageType(url.href) === TYPE_MODULE ? 'module' : 'commonjs';
if (!format) {
- if (esModuleSpecifierResolution === 'node')
+ if (experimentalSpeciferResolution === 'node') {
+ process.emitWarning(
+ 'The Node.js specifier resolution in ESM is experimental.',
+ 'ExperimentalWarning');
format = legacyExtensionFormatMap[ext];
- else
+ } else {
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url));
+ }
}
return { url: `${url}`, format };
}