diff options
author | Myles Borins <mylesborins@google.com> | 2019-10-14 13:28:42 -0400 |
---|---|---|
committer | Guy Bedford <guybedford@gmail.com> | 2019-10-16 22:01:19 -0400 |
commit | 1e5ed9a5db7494d2e415e7937ee0caa4f68e5505 (patch) | |
tree | a2118f05c9efb90f5311e1ebdf137e231f3ff0d2 /lib/internal | |
parent | a6b030d5ac2c4a2d34f6b9eb3f945d252a42843e (diff) | |
download | android-node-v8-1e5ed9a5db7494d2e415e7937ee0caa4f68e5505.tar.gz android-node-v8-1e5ed9a5db7494d2e415e7937ee0caa4f68e5505.tar.bz2 android-node-v8-1e5ed9a5db7494d2e415e7937ee0caa4f68e5505.zip |
esm: modify resolution order for specifier flag
Currently `--es-module-specifier-resolution=node` has an alternative
resolution order than the default in common.js, this causes
inconsistencies. As discussed in @nodejs/modules we want to preserve
resolution order between implementations.
PR-URL: https://github.com/nodejs/node/pull/29974
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal')
-rw-r--r-- | lib/internal/modules/esm/default_resolve.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/internal/modules/esm/default_resolve.js b/lib/internal/modules/esm/default_resolve.js index 7686e3e003..88af3cb5f8 100644 --- a/lib/internal/modules/esm/default_resolve.js +++ b/lib/internal/modules/esm/default_resolve.js @@ -9,6 +9,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 typeFlag = getOptionValue('--input-type'); const experimentalWasmModules = getOptionValue('--experimental-wasm-modules'); const { resolve: moduleWrapResolve, @@ -110,6 +112,8 @@ function resolve(specifier, parentURL) { if (!format) { if (isMain) format = type === TYPE_MODULE ? 'module' : 'commonjs'; + else if (esModuleSpecifierResolution === 'node') + format = 'commonjs'; else throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url)); } |