Skip to content

Commit 22c52aa

Browse files
himself65Trott
authored andcommitted
module: fix specifier resolution option value
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]>
1 parent b7f3e83 commit 22c52aa

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

lib/internal/modules/run_main.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 18 deletions
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(
@@ -368,10 +355,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
368355
"either 'explicit' (default) or 'node'",
369356
&EnvironmentOptions::experimental_specifier_resolution,
370357
kAllowedInEnvironment);
371-
AddOption("--es-module-specifier-resolution",
372-
"",
373-
&EnvironmentOptions::es_module_specifier_resolution,
374-
kAllowedInEnvironment);
358+
AddAlias("--es-module-specifier-resolution",
359+
"--experimental-specifier-resolution");
375360
AddOption("--no-deprecation",
376361
"silence deprecation warnings",
377362
&EnvironmentOptions::no_deprecation,

src/node_options.h

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 9 additions & 4 deletions
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)