summaryrefslogtreecommitdiff
path: root/ext/node/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-02-15 19:44:52 +0100
committerGitHub <noreply@github.com>2023-02-15 19:44:52 +0100
commit75209e12f19ca5d4a2a7c9008fba63a487ad8e6a (patch)
treec122feabbceeef070de4d4eb23667c6153ea7eb1 /ext/node/lib.rs
parentc4b9a91e27a32c0949688034c2449936c01a44a9 (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 'ext/node/lib.rs')
-rw-r--r--ext/node/lib.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index 0987febe8..16d15e677 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -26,7 +26,6 @@ pub use path::PathClean;
pub use polyfill::find_builtin_node_module;
pub use polyfill::is_builtin_node_module;
pub use polyfill::NodeModulePolyfill;
-pub use polyfill::NodeModulePolyfillSpecifier;
pub use polyfill::SUPPORTED_BUILTIN_NODE_MODULES;
pub use resolution::get_closest_package_json;
pub use resolution::get_package_scope_config;
@@ -462,18 +461,15 @@ pub fn init<P: NodePermissions + 'static>(
pub async fn initialize_runtime(
js_runtime: &mut JsRuntime,
- module_all_url: &str,
uses_local_node_modules_dir: bool,
) -> Result<(), AnyError> {
let source_code = &format!(
- r#"(async function loadBuiltinNodeModules(moduleAllUrl, nodeGlobalThisName, usesLocalNodeModulesDir) {{
- const moduleAll = await import(moduleAllUrl);
- Deno[Deno.internal].node.initialize(moduleAll.default, nodeGlobalThisName);
+ r#"(async function loadBuiltinNodeModules(nodeGlobalThisName, usesLocalNodeModulesDir) {{
+ Deno[Deno.internal].node.initialize(Deno[Deno.internal].nodeModuleAll, nodeGlobalThisName);
if (usesLocalNodeModulesDir) {{
Deno[Deno.internal].require.setUsesLocalNodeModulesDir();
}}
- }})('{}', '{}', {});"#,
- module_all_url,
+ }})('{}', {});"#,
NODE_GLOBAL_THIS_NAME.as_str(),
uses_local_node_modules_dir,
);