Skip to content

Commit 99bb0f6

Browse files
fireairforcexusd320
authored andcommitted
fix(pack): loader-runner use path as external (#2274)
1 parent 58c4c86 commit 99bb0f6

File tree

5 files changed

+26
-34
lines changed

5 files changed

+26
-34
lines changed

Cargo.lock

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pack-api/src/project.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,6 @@ impl Project {
864864
let module_graphs_vc = module_graphs_op.connect().resolve().await?;
865865
let _ = module_graphs_op.take_issues();
866866

867-
// At this point all modules have been computed and we can get rid of the node.js
868-
// process pools
869-
if self.await?.watch.enable {
870-
turbopack_node::evaluate::scale_down();
871-
} else {
872-
turbopack_node::evaluate::scale_zero();
873-
}
874-
875867
Ok(module_graphs_vc)
876868
}
877869
.instrument(tracing::info_span!("module graph for project"))

crates/pack-core/src/import_map.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,18 @@ pub async fn get_utoopack_dependency_package(
359359
#[cfg(not(feature = "test"))]
360360
{
361361
let project_root = pack_path.root().owned().await?;
362-
let relative_path = match project_root.get_relative_path_to(dependency_path_to_root) {
363-
Some(relative) => relative,
364-
None => dependency_path_to_root.path.clone(),
362+
let path = if dependency == "loader-runner" {
363+
dependency_path_to_root
364+
.path
365+
.clone()
366+
.replacen("node_modules/", "", 1)
367+
.into()
368+
} else {
369+
project_root
370+
.get_relative_path_to(dependency_path_to_root)
371+
.unwrap_or_else(|| dependency_path_to_root.path.clone())
365372
};
366-
Ok(Vc::cell(relative_path.into()))
373+
Ok(Vc::cell(path))
367374
}
368375
#[cfg(feature = "test")]
369376
{

crates/pack-core/src/shared/webpack_rules/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ use turbo_tasks_fs::FileSystemPath;
88
use turbopack::module_options::{
99
WebpackLoaderBuiltinConditionSet, WebpackLoaderBuiltinConditionSetMatch, WebpackLoadersOptions,
1010
};
11-
use turbopack_core::resolve::{ExternalTraced, ExternalType, options::ImportMapping};
11+
use turbopack_core::resolve::{
12+
ExternalTraced, ExternalType, ResolveResult, ResolveResultItem, options::ImportMapping,
13+
};
1214

1315
use crate::{
1416
config::Config,
17+
import_map::get_utoopack_dependency_package,
1518
shared::webpack_rules::{
1619
less::get_less_loader_rules, sass::get_sass_loader_rules,
1720
style_loader::get_style_loader_rules,
@@ -166,11 +169,14 @@ pub async fn webpack_loader_options(
166169

167170
#[turbo_tasks::function]
168171
async fn loader_runner_package_mapping(pack_path: FileSystemPath) -> Result<Vc<ImportMapping>> {
169-
Ok(ImportMapping::PrimaryAlternativeExternal {
170-
name: Some(rcstr!("loader-runner")),
171-
ty: ExternalType::CommonJs,
172-
traced: ExternalTraced::Untraced,
173-
lookup_dir: pack_path,
174-
}
175-
.cell())
172+
Ok(
173+
ImportMapping::Direct(ResolveResult::primary(ResolveResultItem::External {
174+
name: get_utoopack_dependency_package(pack_path, rcstr!("loader-runner"))
175+
.owned()
176+
.await?,
177+
ty: ExternalType::CommonJs,
178+
traced: ExternalTraced::Untraced,
179+
}))
180+
.cell(),
181+
)
176182
}

0 commit comments

Comments
 (0)