From fab27dabed3a4d0478b28c86809cc06482b2c45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 24 Jan 2024 21:00:05 +0900 Subject: [PATCH] fix(es/loader): Don't use browser versions for `jsc.paths` (#8548) **Related issue:** - https://github.com/vercel/next.js/issues/56144 --- crates/swc/src/config/mod.rs | 14 +++++++++----- crates/swc/src/lib.rs | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 37ee8e388411..2ef8ab058eec 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -1747,12 +1747,16 @@ fn build_resolver( } let r = { - let r = TsConfigResolver::new( - NodeModulesResolver::without_node_modules(Default::default(), Default::default(), true), - base_url.clone(), - paths.clone(), + let r = NodeModulesResolver::without_node_modules( + swc_ecma_loader::TargetEnv::Node, + Default::default(), + true, ); - let r = CachingResolver::new(40, r); + + let r = CachingResolver::new(1024, r); + + let r = TsConfigResolver::new(r, base_url.clone(), paths.clone()); + let r = CachingResolver::new(256, r); let r = NodeImportResolver::with_config( r, diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index 051b3a7ed4a6..c8a108a8b1ca 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -203,8 +203,9 @@ pub mod resolver { } } -type SwcImportResolver = - Arc>>>; +type SwcImportResolver = Arc< + NodeImportResolver>>>, +>; /// All methods accept [Handler], which is a storage for errors. ///