Skip to content

Commit

Permalink
module: fix specifier resolution option value
Browse files Browse the repository at this point in the history
Fixes: #35095

PR-URL: #35098
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
himself65 authored and ruyadorno committed Sep 17, 2020
1 parent 379c5ce commit 314483c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/internal/modules/run_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function shouldUseESMLoader(mainPath) {
if (userLoader)
return true;
const esModuleSpecifierResolution =
getOptionValue('--es-module-specifier-resolution');
getOptionValue('--experimental-specifier-resolution');
if (esModuleSpecifierResolution === 'node')
return true;
// Determine the module format of the main
Expand Down
21 changes: 3 additions & 18 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
}
}

if (!es_module_specifier_resolution.empty()) {
if (!experimental_specifier_resolution.empty()) {
errors->push_back(
"bad option: cannot use --es-module-specifier-resolution"
" and --experimental-specifier-resolution at the same time");
} else {
experimental_specifier_resolution = es_module_specifier_resolution;
if (experimental_specifier_resolution != "node" &&
experimental_specifier_resolution != "explicit") {
errors->push_back(
"invalid value for --es-module-specifier-resolution");
}
}
} else if (!experimental_specifier_resolution.empty()) {
if (!experimental_specifier_resolution.empty()) {
if (experimental_specifier_resolution != "node" &&
experimental_specifier_resolution != "explicit") {
errors->push_back(
Expand Down Expand Up @@ -366,10 +353,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"either 'explicit' (default) or 'node'",
&EnvironmentOptions::experimental_specifier_resolution,
kAllowedInEnvironment);
AddOption("--es-module-specifier-resolution",
"",
&EnvironmentOptions::es_module_specifier_resolution,
kAllowedInEnvironment);
AddAlias("--es-module-specifier-resolution",
"--experimental-specifier-resolution");
AddOption("--no-deprecation",
"silence deprecation warnings",
&EnvironmentOptions::no_deprecation,
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class EnvironmentOptions : public Options {
bool experimental_json_modules = false;
bool experimental_modules = false;
std::string experimental_specifier_resolution;
std::string es_module_specifier_resolution;
bool experimental_wasm_modules = false;
bool experimental_import_meta_resolve = false;
std::string module_type;
Expand Down
14 changes: 0 additions & 14 deletions test/es-module/test-esm-specifiers-both-flags.mjs

This file was deleted.

13 changes: 9 additions & 4 deletions test/es-module/test-esm-specifiers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ main().catch(mustNotCall);
'../../fixtures/es-module-specifiers',
item,
);
spawn(process.execPath,
['--es-module-specifier-resolution=node', modulePath],
{ stdio: 'inherit' }).on('exit', (code) => {
assert.strictEqual(code, 0);
[
'--experimental-specifier-resolution',
'--es-module-specifier-resolution'
].forEach((option) => {
spawn(process.execPath,
[`${option}=node`, modulePath],
{ stdio: 'inherit' }).on('exit', (code) => {
assert.strictEqual(code, 0);
});
});
});

0 comments on commit 314483c

Please sign in to comment.