diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-10 14:46:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 14:46:25 -0400 |
commit | a49d0bd10ba2a4745c291f3f413d97396213e4ec (patch) | |
tree | 0c63c25304f465e969d2bcfb8bd71df8575c4033 /cli/standalone | |
parent | 4d2d764816d266e42f3b2251248b100abb667c83 (diff) |
fix(check): CJS types importing dual ESM/CJS package should prefer CJS types (#24492)
Closes #16370
Diffstat (limited to 'cli/standalone')
-rw-r--r-- | cli/standalone/binary.rs | 21 | ||||
-rw-r--r-- | cli/standalone/mod.rs | 5 |
2 files changed, 14 insertions, 12 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 4d6b32b7d..10a762093 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -69,7 +69,7 @@ pub enum NodeModules { node_modules_dir: Option<String>, }, Byonm { - root_node_modules_dir: String, + root_node_modules_dir: Option<String>, }, } @@ -572,15 +572,16 @@ impl<'a> DenoCompileBinaryWriter<'a> { Some(root_dir), files, Some(NodeModules::Byonm { - root_node_modules_dir: root_dir_url - .specifier_key( - &ModuleSpecifier::from_directory_path( - // will always be set for byonm - resolver.root_node_modules_path().unwrap(), - ) - .unwrap(), - ) - .into_owned(), + root_node_modules_dir: resolver.root_node_modules_path().map( + |node_modules_dir| { + root_dir_url + .specifier_key( + &ModuleSpecifier::from_directory_path(node_modules_dir) + .unwrap(), + ) + .into_owned() + }, + ), }), ) } diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 796551729..1df3895ef 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -490,7 +490,8 @@ pub async fn run( let vfs_root_dir_path = root_path.clone(); let vfs = load_npm_vfs(vfs_root_dir_path.clone()) .context("Failed to load vfs.")?; - let root_node_modules_dir = vfs.root().join(root_node_modules_dir); + let root_node_modules_dir = + root_node_modules_dir.map(|p| vfs.root().join(p)); let fs = Arc::new(DenoCompileFileSystem::new(vfs)) as Arc<dyn deno_fs::FileSystem>; let npm_resolver = create_cli_npm_resolver( @@ -584,7 +585,7 @@ pub async fn run( ) }; let cli_node_resolver = Arc::new(CliNodeResolver::new( - Some(cjs_resolutions.clone()), + cjs_resolutions.clone(), fs.clone(), node_resolver.clone(), npm_resolver.clone(), |