Skip to content

Commit 314483c

Browse files
himself65ruyadorno
authored andcommitted
module: fix specifier resolution option value
Fixes: #35095 PR-URL: #35098 Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 379c5ce commit 314483c

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

lib/internal/modules/run_main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function shouldUseESMLoader(mainPath) {
2525
if (userLoader)
2626
return true;
2727
const esModuleSpecifierResolution =
28-
getOptionValue('--es-module-specifier-resolution');
28+
getOptionValue('--experimental-specifier-resolution');
2929
if (esModuleSpecifierResolution === 'node')
3030
return true;
3131
// Determine the module format of the main

src/node_options.cc

+3-18
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
9292
}
9393
}
9494

95-
if (!es_module_specifier_resolution.empty()) {
96-
if (!experimental_specifier_resolution.empty()) {
97-
errors->push_back(
98-
"bad option: cannot use --es-module-specifier-resolution"
99-
" and --experimental-specifier-resolution at the same time");
100-
} else {
101-
experimental_specifier_resolution = es_module_specifier_resolution;
102-
if (experimental_specifier_resolution != "node" &&
103-
experimental_specifier_resolution != "explicit") {
104-
errors->push_back(
105-
"invalid value for --es-module-specifier-resolution");
106-
}
107-
}
108-
} else if (!experimental_specifier_resolution.empty()) {
95+
if (!experimental_specifier_resolution.empty()) {
10996
if (experimental_specifier_resolution != "node" &&
11097
experimental_specifier_resolution != "explicit") {
11198
errors->push_back(
@@ -366,10 +353,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
366353
"either 'explicit' (default) or 'node'",
367354
&EnvironmentOptions::experimental_specifier_resolution,
368355
kAllowedInEnvironment);
369-
AddOption("--es-module-specifier-resolution",
370-
"",
371-
&EnvironmentOptions::es_module_specifier_resolution,
372-
kAllowedInEnvironment);
356+
AddAlias("--es-module-specifier-resolution",
357+
"--experimental-specifier-resolution");
373358
AddOption("--no-deprecation",
374359
"silence deprecation warnings",
375360
&EnvironmentOptions::no_deprecation,

src/node_options.h

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class EnvironmentOptions : public Options {
105105
bool experimental_json_modules = false;
106106
bool experimental_modules = false;
107107
std::string experimental_specifier_resolution;
108-
std::string es_module_specifier_resolution;
109108
bool experimental_wasm_modules = false;
110109
bool experimental_import_meta_resolve = false;
111110
std::string module_type;

test/es-module/test-esm-specifiers-both-flags.mjs

-14
This file was deleted.

test/es-module/test-esm-specifiers.mjs

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ main().catch(mustNotCall);
4949
'../../fixtures/es-module-specifiers',
5050
item,
5151
);
52-
spawn(process.execPath,
53-
['--es-module-specifier-resolution=node', modulePath],
54-
{ stdio: 'inherit' }).on('exit', (code) => {
55-
assert.strictEqual(code, 0);
52+
[
53+
'--experimental-specifier-resolution',
54+
'--es-module-specifier-resolution'
55+
].forEach((option) => {
56+
spawn(process.execPath,
57+
[`${option}=node`, modulePath],
58+
{ stdio: 'inherit' }).on('exit', (code) => {
59+
assert.strictEqual(code, 0);
60+
});
5661
});
5762
});

0 commit comments

Comments
 (0)