Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRongjian Zhang <pd4d10@gmail.com>2019-11-24 07:40:40 +0300
committerMichaƫl Zasso <targos@protonmail.com>2019-12-09 12:23:06 +0300
commit851f3135aba0fdbf0fc89f1ef346adf438f4c399 (patch)
treecfea5f1aa81bdd5746031f4c18a78e420a1442c7 /src
parent55a270b5837b2c4a2a63fc6a7ef4dcd85856a3bd (diff)
module: add warnings for experimental flags
PR-URL: https://github.com/nodejs/node/pull/30617 Fixes: https://github.com/nodejs/node/issues/30600 Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/module_wrap.cc3
-rw-r--r--src/node_process.h2
-rw-r--r--src/node_process_events.cc16
3 files changed, 21 insertions, 0 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 3c3d5683292..2fa8ba498ed 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -7,6 +7,7 @@
#include "util-inl.h"
#include "node_contextify.h"
#include "node_watchdog.h"
+#include "node_process.h"
#include <sys/stat.h> // S_IFDIR
@@ -962,6 +963,7 @@ Maybe<URL> ResolveExportsTarget(Environment* env,
Maybe<URL> resolved = ResolveExportsTarget(env, pjson_url,
conditionalTarget, subpath, pkg_subpath, base, false);
if (!resolved.IsNothing()) {
+ ProcessEmitExperimentalWarning(env, "Conditional exports");
return resolved;
}
}
@@ -1267,6 +1269,7 @@ Maybe<URL> PackageResolve(Environment* env,
Maybe<URL> self_url = ResolveSelf(env, specifier, base);
if (self_url.IsJust()) {
+ ProcessEmitExperimentalWarning(env, "Package name self resolution");
return self_url;
}
diff --git a/src/node_process.h b/src/node_process.h
index 5db7b004d6f..ad86b449f95 100644
--- a/src/node_process.h
+++ b/src/node_process.h
@@ -27,6 +27,8 @@ v8::Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
const char* code = nullptr);
v8::Maybe<bool> ProcessEmitWarning(Environment* env, const char* fmt, ...);
+v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env,
+ const char* warning);
v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env,
const char* warning,
const char* deprecation_code);
diff --git a/src/node_process_events.cc b/src/node_process_events.cc
index 06096226625..d192ef19b7a 100644
--- a/src/node_process_events.cc
+++ b/src/node_process_events.cc
@@ -1,4 +1,5 @@
#include <cstdarg>
+#include <set>
#include "env-inl.h"
#include "node_process.h"
@@ -95,6 +96,21 @@ Maybe<bool> ProcessEmitWarning(Environment* env, const char* fmt, ...) {
return ProcessEmitWarningGeneric(env, warning);
}
+
+std::set<std::string> experimental_warnings;
+
+Maybe<bool> ProcessEmitExperimentalWarning(Environment* env,
+ const char* warning) {
+ if (experimental_warnings.find(warning) != experimental_warnings.end())
+ return Nothing<bool>();
+
+ experimental_warnings.insert(warning);
+ std::string message(warning);
+ message.append(
+ " is an experimental feature. This feature could change at any time");
+ return ProcessEmitWarningGeneric(env, message.c_str(), "ExperimentalWarning");
+}
+
Maybe<bool> ProcessEmitDeprecationWarning(Environment* env,
const char* warning,
const char* deprecation_code) {