summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/mod.rs4
-rw-r--r--cli/factory.rs1
-rw-r--r--cli/standalone/mod.rs1
-rw-r--r--cli/worker.rs5
-rw-r--r--runtime/js/99_main.js5
-rw-r--r--runtime/worker_bootstrap.rs5
-rw-r--r--test_util/src/builders.rs5
-rw-r--r--tests/integration/run_tests.rs10
-rw-r--r--tests/testdata/run/deno_futures_env.ts3
9 files changed, 39 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 6aafd0ea6..d7ff91b84 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -987,6 +987,10 @@ impl CliOptions {
}
}
+ pub fn enable_future_features(&self) -> bool {
+ std::env::var("DENO_FUTURE").is_ok()
+ }
+
pub fn resolve_main_module(&self) -> Result<ModuleSpecifier, AnyError> {
match &self.flags.subcommand {
DenoSubcommand::Bundle(bundle_flags) => {
diff --git a/cli/factory.rs b/cli/factory.rs
index be2dc677d..2236e6090 100644
--- a/cli/factory.rs
+++ b/cli/factory.rs
@@ -775,6 +775,7 @@ impl CliFactory {
self.feature_checker().clone(),
self.create_cli_main_worker_options()?,
self.options.node_ipc_fd(),
+ self.options.enable_future_features(),
// TODO(bartlomieju): temporarily disabled
// self.options.disable_deprecated_api_warning,
true,
diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs
index ecbb0be82..d1b90ecee 100644
--- a/cli/standalone/mod.rs
+++ b/cli/standalone/mod.rs
@@ -551,6 +551,7 @@ pub async fn run(
create_coverage_collector: None,
},
None,
+ false,
// TODO(bartlomieju): temporarily disabled
// metadata.disable_deprecated_api_warning,
true,
diff --git a/cli/worker.rs b/cli/worker.rs
index 3f75ebc5c..5c252e92c 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -144,6 +144,7 @@ struct SharedWorkerState {
maybe_lockfile: Option<Arc<Mutex<Lockfile>>>,
feature_checker: Arc<FeatureChecker>,
node_ipc: Option<i64>,
+ enable_future_features: bool,
disable_deprecated_api_warning: bool,
verbose_deprecated_api_warning: bool,
}
@@ -424,6 +425,7 @@ impl CliMainWorkerFactory {
feature_checker: Arc<FeatureChecker>,
options: CliMainWorkerOptions,
node_ipc: Option<i64>,
+ enable_future_features: bool,
disable_deprecated_api_warning: bool,
verbose_deprecated_api_warning: bool,
) -> Self {
@@ -446,6 +448,7 @@ impl CliMainWorkerFactory {
maybe_lockfile,
feature_checker,
node_ipc,
+ enable_future_features,
disable_deprecated_api_warning,
verbose_deprecated_api_warning,
}),
@@ -612,6 +615,7 @@ impl CliMainWorkerFactory {
node_ipc_fd: shared.node_ipc,
disable_deprecated_api_warning: shared.disable_deprecated_api_warning,
verbose_deprecated_api_warning: shared.verbose_deprecated_api_warning,
+ future: shared.enable_future_features,
},
extensions: custom_extensions,
startup_snapshot: crate::js::deno_isolate_init(),
@@ -818,6 +822,7 @@ fn create_web_worker_callback(
node_ipc_fd: None,
disable_deprecated_api_warning: shared.disable_deprecated_api_warning,
verbose_deprecated_api_warning: shared.verbose_deprecated_api_warning,
+ future: false,
},
extensions: vec![],
startup_snapshot: crate::js::deno_isolate_init(),
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 965af460d..11c26798b 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -647,6 +647,7 @@ function bootstrapMainRuntime(runtimeOptions) {
6: maybeBinaryNpmCommandName,
7: shouldDisableDeprecatedApiWarning,
8: shouldUseVerboseDeprecatedApiWarning,
+ 9: future,
} = runtimeOptions;
removeImportedOps();
@@ -769,6 +770,10 @@ function bootstrapMainRuntime(runtimeOptions) {
if (nodeBootstrap) {
nodeBootstrap(hasNodeModulesDir, maybeBinaryNpmCommandName);
}
+
+ if (future) {
+ delete globalThis.window;
+ }
}
function bootstrapWorkerRuntime(
diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs
index ca2d4d8ec..300829630 100644
--- a/runtime/worker_bootstrap.rs
+++ b/runtime/worker_bootstrap.rs
@@ -62,6 +62,7 @@ pub struct BootstrapOptions {
pub node_ipc_fd: Option<i64>,
pub disable_deprecated_api_warning: bool,
pub verbose_deprecated_api_warning: bool,
+ pub future: bool,
}
impl Default for BootstrapOptions {
@@ -92,6 +93,7 @@ impl Default for BootstrapOptions {
node_ipc_fd: None,
disable_deprecated_api_warning: false,
verbose_deprecated_api_warning: false,
+ future: false,
}
}
}
@@ -125,6 +127,8 @@ struct BootstrapV8<'a>(
bool,
// verbose_deprecated_api_warning
bool,
+ // future
+ bool,
);
impl BootstrapOptions {
@@ -146,6 +150,7 @@ impl BootstrapOptions {
self.maybe_binary_npm_command_name.as_deref(),
self.disable_deprecated_api_warning,
self.verbose_deprecated_api_warning,
+ self.future,
);
bootstrap.serialize(ser).unwrap()
diff --git a/test_util/src/builders.rs b/test_util/src/builders.rs
index 4c655f1e5..9bbe6693f 100644
--- a/test_util/src/builders.rs
+++ b/test_util/src/builders.rs
@@ -166,6 +166,11 @@ impl TestContextBuilder {
self
}
+ pub fn add_future_env_vars(mut self) -> Self {
+ self = self.env("DENO_FUTURE", "1");
+ self
+ }
+
pub fn add_jsr_env_vars(mut self) -> Self {
for (key, value) in env_vars_for_jsr_tests() {
self = self.env(key, value);
diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs
index c9508594c..6f108f739 100644
--- a/tests/integration/run_tests.rs
+++ b/tests/integration/run_tests.rs
@@ -1711,6 +1711,16 @@ fn type_directives_js_main() {
assert_not_contains!(output.combined_output(), "type_reference.d.ts");
}
+#[test]
+fn test_deno_futures_env() {
+ let context = TestContextBuilder::new().add_future_env_vars().build();
+ let output = context
+ .new_command()
+ .args("run --quiet --reload run/deno_futures_env.ts")
+ .run();
+ output.assert_exit_code(0);
+}
+
itest!(type_directives_redirect {
args: "run --reload --check run/type_directives_redirect.ts",
output: "run/type_directives_redirect.ts.out",
diff --git a/tests/testdata/run/deno_futures_env.ts b/tests/testdata/run/deno_futures_env.ts
new file mode 100644
index 000000000..21f76e367
--- /dev/null
+++ b/tests/testdata/run/deno_futures_env.ts
@@ -0,0 +1,3 @@
+if (typeof window !== "undefined") {
+ throw new Error("Window global available");
+}