diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-10-06 19:07:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 19:07:04 +0200 |
commit | b686907a45bb7d113f863cca7c52754027e449c0 (patch) | |
tree | 9bc296cc2ade609c4276fce1f14128338c0e6f1f /cli/proc_state.rs | |
parent | b033a7a6d4ac6f1d3e20b5d113cca2fd85cacfc3 (diff) |
feat(compat): inject Node globals (#12342)
This commit adds automatic injection of Node globals when "--compat" flag
is present.
This is done by executing "https://deno.land/std/node/global.ts" as a "side module",
before main module is executed.
This commit makes "--compat" required to be used with "--unstable" flag, as some
of Node globals require unstable Deno APIs.
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 48dc335f0..2e1fb0e31 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -1,6 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use crate::colors; +use crate::compat; use crate::config_file::ConfigFile; use crate::deno_dir; use crate::file_fetcher::CacheSetting; @@ -217,7 +218,7 @@ impl ProcState { .unwrap() } }; - let node_builtins = crate::compat::get_mapped_node_builtins(); + let node_builtins = compat::get_mapped_node_builtins(); let diagnostics = import_map.update_imports(node_builtins)?; if !diagnostics.is_empty() { @@ -353,6 +354,9 @@ impl ProcState { )?)); let mut builder = GraphBuilder::new(handler, maybe_import_map, self.lockfile.clone()); + if self.flags.compat { + builder.add(&compat::get_node_globals_url(), false).await?; + } builder.add(&specifier, is_dynamic).await?; builder.analyze_config_file(&self.maybe_config_file).await?; let mut graph = builder.get_graph(); |