diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-15 19:44:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 19:44:52 +0100 |
commit | 75209e12f19ca5d4a2a7c9008fba63a487ad8e6a (patch) | |
tree | c122feabbceeef070de4d4eb23667c6153ea7eb1 /cli/worker.rs | |
parent | c4b9a91e27a32c0949688034c2449936c01a44a9 (diff) |
feat: wire up ext/node to the Node compatibility layer (#17785)
This PR changes Node.js/npm compatibility layer to use polyfills for
built-in Node.js
embedded in the snapshot (that are coming from "ext/node" extension).
As a result loading `std/node`, either from
"https://deno.land/std@<latest>/" or
from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is
imported via "npm:" specifiers now uses code embedded in the snapshot.
Several fixes were applied to various modules in "ext/node" to make
tests pass.
---------
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 558513b8d..72126d44f 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -67,7 +67,6 @@ impl CliMainWorker { log::debug!("main_module {}", self.main_module); if self.is_main_cjs { - self.ps.prepare_node_std_graph().await?; self.initialize_main_module_for_node().await?; deno_node::load_cjs_module( &mut self.worker.js_runtime, @@ -279,9 +278,6 @@ impl CliMainWorker { async fn execute_main_module_possibly_with_npm( &mut self, ) -> Result<(), AnyError> { - if self.ps.npm_resolver.has_packages() { - self.ps.prepare_node_std_graph().await?; - } let id = self.worker.preload_main_module(&self.main_module).await?; self.evaluate_module_possibly_with_npm(id).await } @@ -297,17 +293,17 @@ impl CliMainWorker { &mut self, id: ModuleId, ) -> Result<(), AnyError> { - if self.ps.npm_resolver.has_packages() { + if self.ps.npm_resolver.has_packages() + || self.ps.has_node_builtin_specifier() + { self.initialize_main_module_for_node().await?; } self.worker.evaluate_module(id).await } async fn initialize_main_module_for_node(&mut self) -> Result<(), AnyError> { - self.ps.prepare_node_std_graph().await?; deno_node::initialize_runtime( &mut self.worker.js_runtime, - node::MODULE_ALL_URL.as_str(), self.ps.options.node_modules_dir(), ) .await?; @@ -630,7 +626,6 @@ fn create_web_worker_pre_execute_module_callback( if ps.npm_resolver.has_packages() { deno_node::initialize_runtime( &mut worker.js_runtime, - node::MODULE_ALL_URL.as_str(), ps.options.node_modules_dir(), ) .await?; |