summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMyles Borins <mylesborins@google.com>2019-11-27 01:54:23 -0500
committerMyles Borins <mylesborins@google.com>2019-12-04 13:21:41 -0800
commitee953d813be1fb19930e0e64196c0aa33699b133 (patch)
tree2b11d0315bcbb33ee26ad333a798ff012da696fa /src
parent12254ce242c30d403b523ad9adb60a0280080957 (diff)
downloadandroid-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.tar.gz
android-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.tar.bz2
android-node-v8-ee953d813be1fb19930e0e64196c0aa33699b133.zip
esm: make specifier flag clearly experimental
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: https://github.com/nodejs/node/pull/30678 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/module_wrap.cc4
-rw-r--r--src/node_options.cc26
-rw-r--r--src/node_options.h1
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;