From a49d0bd10ba2a4745c291f3f413d97396213e4ec Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 10 Jul 2024 14:46:25 -0400 Subject: fix(check): CJS types importing dual ESM/CJS package should prefer CJS types (#24492) Closes #16370 --- cli/standalone/binary.rs | 21 +++++++++++---------- cli/standalone/mod.rs | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'cli/standalone') 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, }, Byonm { - root_node_modules_dir: String, + root_node_modules_dir: Option, }, } @@ -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; 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(), -- cgit v1.2.3