diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/module_wrap.cc | 4 | ||||
-rw-r--r-- | src/node_options.cc | 26 | ||||
-rw-r--r-- | src/node_options.h | 1 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 5745cce9e0..3c3d568329 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -789,7 +789,7 @@ inline Maybe<URL> ResolveIndex(const URL& search) { Maybe<URL> FinalizeResolution(Environment* env, const URL& resolved, const URL& base) { - if (env->options()->es_module_specifier_resolution == "node") { + if (env->options()->experimental_specifier_resolution == "node") { Maybe<URL> file = ResolveExtensions<TRY_EXACT_NAME>(resolved); if (!file.IsNothing()) { return file; @@ -1053,7 +1053,7 @@ Maybe<URL> PackageMainResolve(Environment* env, return Just(resolved); } } - if (env->options()->es_module_specifier_resolution == "node") { + if (env->options()->experimental_specifier_resolution == "node") { if (pcfg.has_main == HasMain::Yes) { return FinalizeResolution(env, URL(pcfg.main, pjson_url), base); } else { diff --git a/src/node_options.cc b/src/node_options.cc index 498bedd1e5..abf26fb781 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -128,9 +128,23 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) { } if (!es_module_specifier_resolution.empty()) { - if (es_module_specifier_resolution != "node" && - es_module_specifier_resolution != "explicit") { - errors->push_back("invalid value for --es-module-specifier-resolution"); + 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 != "node" && + experimental_specifier_resolution != "explicit") { + errors->push_back( + "invalid value for --experimental-specifier-resolution"); } } @@ -365,9 +379,13 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "set module type for string input", &EnvironmentOptions::module_type, kAllowedInEnvironment); - AddOption("--es-module-specifier-resolution", + AddOption("--experimental-specifier-resolution", "Select extension resolution algorithm for es modules; " "either 'explicit' (default) or 'node'", + &EnvironmentOptions::experimental_specifier_resolution, + kAllowedInEnvironment); + AddOption("--es-module-specifier-resolution", + "", &EnvironmentOptions::es_module_specifier_resolution, kAllowedInEnvironment); AddOption("--no-deprecation", diff --git a/src/node_options.h b/src/node_options.h index fea912da44..c4cb5dc04f 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -104,6 +104,7 @@ class EnvironmentOptions : public Options { bool experimental_conditional_exports = false; bool experimental_json_modules = false; bool experimental_resolve_self = false; + std::string experimental_specifier_resolution; std::string es_module_specifier_resolution; bool experimental_wasm_modules = false; std::string module_type; |