From 28aa489de9cd4f995ec2fc02e2c9d224e89f4c01 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 10 May 2023 20:06:59 -0400 Subject: feat(compile): unstable npm and node specifier support (#19005) This is the initial support for npm and node specifiers in `deno compile`. The npm packages are included in the binary and read from it via a virtual file system. This also supports the `--node-modules-dir` flag, dependencies specified in a package.json, and npm binary commands (ex. `deno compile --unstable npm:cowsay`) Closes #16632 --- cli/npm/resolvers/common.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cli/npm/resolvers/common.rs') diff --git a/cli/npm/resolvers/common.rs b/cli/npm/resolvers/common.rs index ccba00d43..fc040a7cc 100644 --- a/cli/npm/resolvers/common.rs +++ b/cli/npm/resolvers/common.rs @@ -12,6 +12,7 @@ use deno_core::futures; use deno_core::url::Url; use deno_npm::NpmPackageId; use deno_npm::NpmResolutionPackage; +use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::NodePermissions; use deno_runtime::deno_node::NodeResolutionMode; @@ -90,6 +91,7 @@ pub async fn cache_packages( } pub fn ensure_registry_read_permission( + fs: &Arc, permissions: &dyn NodePermissions, registry_path: &Path, path: &Path, @@ -101,8 +103,8 @@ pub fn ensure_registry_read_permission( .all(|c| !matches!(c, std::path::Component::ParentDir)) { // todo(dsherret): cache this? - if let Ok(registry_path) = std::fs::canonicalize(registry_path) { - match std::fs::canonicalize(path) { + if let Ok(registry_path) = fs.realpath_sync(registry_path) { + match fs.realpath_sync(path) { Ok(path) if path.starts_with(registry_path) => { return Ok(()); } -- cgit v1.2.3