Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(turbopack): Use ResolvedVc for turbopack-core #72798

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5b3858a
Replace using ast-grep
kdy1 Nov 14, 2024
2913f77
Some work
kdy1 Nov 14, 2024
71b9c7b
Fix
kdy1 Nov 14, 2024
ed9919b
Fix
kdy1 Nov 14, 2024
0216e93
default
kdy1 Nov 14, 2024
fc078cd
Fix more
kdy1 Nov 14, 2024
32fb6ee
Fix more
kdy1 Nov 14, 2024
18e37aa
Fix more
kdy1 Nov 14, 2024
e5906c4
Fix more
kdy1 Nov 14, 2024
0da87f3
Fix more
kdy1 Nov 14, 2024
8494cf1
Revert some
kdy1 Nov 14, 2024
3316db4
More fix
kdy1 Nov 14, 2024
93ce08b
More fix
kdy1 Nov 14, 2024
56471de
Revert some
kdy1 Nov 14, 2024
1cfcba8
More fix
kdy1 Nov 14, 2024
6f5206e
More fix
kdy1 Nov 14, 2024
84a532e
fix more
kdy1 Nov 14, 2024
5f378ee
fix `turbopack`
kdy1 Nov 14, 2024
47d1f45
More fix for next crates
kdy1 Nov 14, 2024
3c16ff0
fix more
kdy1 Nov 14, 2024
d2837db
fix more
kdy1 Nov 14, 2024
9a9521b
fix more
kdy1 Nov 14, 2024
a18d97f
fix more
kdy1 Nov 14, 2024
16e2f15
fix more
kdy1 Nov 14, 2024
fd0a1b7
fix more
kdy1 Nov 14, 2024
f66cdbb
fix more
kdy1 Nov 14, 2024
02ec46a
fix more
kdy1 Nov 14, 2024
2557f49
fix more
kdy1 Nov 14, 2024
1a7e5ef
fix more
kdy1 Nov 14, 2024
61b2bac
fix more
kdy1 Nov 14, 2024
c5dd8a9
fix more
kdy1 Nov 14, 2024
33f7fde
fix more
kdy1 Nov 14, 2024
26b7e19
fix more
kdy1 Nov 14, 2024
296e13b
fix more
kdy1 Nov 14, 2024
7c52bc7
fix more
kdy1 Nov 14, 2024
6695bc3
fix more
kdy1 Nov 14, 2024
72da07e
fix more
kdy1 Nov 14, 2024
744a38a
fix more
kdy1 Nov 14, 2024
94ebacd
refactor(turbopack): Use `ResolvedVc` for `turbopack-core`
kdy1 Nov 14, 2024
eaea426
More fix
kdy1 Nov 14, 2024
91b58e8
More fix
kdy1 Nov 14, 2024
5dadebb
More fix
kdy1 Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 66 additions & 36 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,32 @@ impl AppProject {
}

#[turbo_tasks::function]
fn rsc_module_context(self: Vc<Self>) -> Vc<ModuleAssetContext> {
async fn rsc_module_context(self: Vc<Self>) -> Result<Vc<ModuleAssetContext>> {
let transitions = [
(
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
self.client_reference_transition(),
self.client_reference_transition().to_resolved().await?,
),
(
"next-dynamic".into(),
Vc::upcast(NextDynamicTransition::new(Vc::upcast(
self.client_transition(),
))),
ResolvedVc::upcast(
NextDynamicTransition::new(Vc::upcast(self.client_transition()))
.to_resolved()
.await?,
),
),
(
"next-ssr".into(),
ResolvedVc::upcast(self.ssr_transition().to_resolved().await?),
),
(
"next-shared".into(),
ResolvedVc::upcast(self.shared_transition().to_resolved().await?),
),
("next-ssr".into(), Vc::upcast(self.ssr_transition())),
("next-shared".into(), Vc::upcast(self.shared_transition())),
]
.into_iter()
.collect();
ModuleAssetContext::new(
Ok(ModuleAssetContext::new(
TransitionOptions {
named_transitions: transitions,
transition_rules: vec![TransitionRule::new(
Expand All @@ -340,31 +348,38 @@ impl AppProject {
self.rsc_module_options_context(),
self.rsc_resolve_options_context(),
Vc::cell("app-rsc".into()),
)
))
}

#[turbo_tasks::function]
fn edge_rsc_module_context(self: Vc<Self>) -> Vc<ModuleAssetContext> {
async fn edge_rsc_module_context(self: Vc<Self>) -> Result<Vc<ModuleAssetContext>> {
let transitions = [
(
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
self.edge_client_reference_transition(),
self.edge_client_reference_transition()
.to_resolved()
.await?,
),
(
"next-dynamic".into(),
Vc::upcast(NextDynamicTransition::new(Vc::upcast(
self.client_transition(),
))),
ResolvedVc::upcast(
NextDynamicTransition::new(Vc::upcast(self.client_transition()))
.to_resolved()
.await?,
),
),
(
"next-ssr".into(),
ResolvedVc::upcast(self.edge_ssr_transition().to_resolved().await?),
),
("next-ssr".into(), Vc::upcast(self.edge_ssr_transition())),
(
"next-shared".into(),
Vc::upcast(self.edge_shared_transition()),
ResolvedVc::upcast(self.edge_shared_transition().to_resolved().await?),
),
]
.into_iter()
.collect();
ModuleAssetContext::new(
Ok(ModuleAssetContext::new(
TransitionOptions {
named_transitions: transitions,
transition_rules: vec![TransitionRule::new(
Expand All @@ -378,29 +393,37 @@ impl AppProject {
self.edge_rsc_module_options_context(),
self.edge_rsc_resolve_options_context(),
Vc::cell("app-edge-rsc".into()),
)
))
}

#[turbo_tasks::function]
fn route_module_context(self: Vc<Self>) -> Vc<ModuleAssetContext> {
async fn route_module_context(self: Vc<Self>) -> Result<Vc<ModuleAssetContext>> {
let transitions = [
(
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
self.client_reference_transition(),
self.client_reference_transition().to_resolved().await?,
),
(
"next-dynamic".into(),
Vc::upcast(NextDynamicTransition::new(Vc::upcast(
self.client_transition(),
))),
ResolvedVc::upcast(
NextDynamicTransition::new(Vc::upcast(self.client_transition()))
.to_resolved()
.await?,
),
),
(
"next-ssr".into(),
ResolvedVc::upcast(self.ssr_transition().to_resolved().await?),
),
(
"next-shared".into(),
ResolvedVc::upcast(self.shared_transition().to_resolved().await?),
),
("next-ssr".into(), Vc::upcast(self.ssr_transition())),
("next-shared".into(), Vc::upcast(self.shared_transition())),
]
.into_iter()
.collect();

ModuleAssetContext::new(
Ok(ModuleAssetContext::new(
TransitionOptions {
named_transitions: transitions,
..Default::default()
Expand All @@ -410,31 +433,38 @@ impl AppProject {
self.route_module_options_context(),
self.route_resolve_options_context(),
Vc::cell("app-route".into()),
)
))
}

#[turbo_tasks::function]
fn edge_route_module_context(self: Vc<Self>) -> Vc<ModuleAssetContext> {
async fn edge_route_module_context(self: Vc<Self>) -> Result<Vc<ModuleAssetContext>> {
let transitions = [
(
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
self.edge_client_reference_transition(),
self.edge_client_reference_transition()
.to_resolved()
.await?,
),
(
"next-dynamic".into(),
Vc::upcast(NextDynamicTransition::new(Vc::upcast(
self.client_transition(),
))),
ResolvedVc::upcast(
NextDynamicTransition::new(Vc::upcast(self.client_transition()))
.to_resolved()
.await?,
),
),
(
"next-ssr".into(),
ResolvedVc::upcast(self.edge_ssr_transition().to_resolved().await?),
),
("next-ssr".into(), Vc::upcast(self.ssr_transition())),
(
"next-shared".into(),
Vc::upcast(self.edge_shared_transition()),
ResolvedVc::upcast(self.edge_shared_transition().to_resolved().await?),
),
]
.into_iter()
.collect();
ModuleAssetContext::new(
Ok(ModuleAssetContext::new(
TransitionOptions {
named_transitions: transitions,
..Default::default()
Expand All @@ -444,7 +474,7 @@ impl AppProject {
self.edge_route_module_options_context(),
self.edge_route_resolve_options_context(),
Vc::cell("app-edge-route".into()),
)
))
}

#[turbo_tasks::function]
Expand Down
14 changes: 8 additions & 6 deletions crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,21 @@ impl PagesProject {
}

#[turbo_tasks::function]
fn transitions(self: Vc<Self>) -> Vc<TransitionOptions> {
TransitionOptions {
async fn transitions(self: Vc<Self>) -> Result<Vc<TransitionOptions>> {
Ok(TransitionOptions {
named_transitions: [(
"next-dynamic".into(),
Vc::upcast(NextDynamicTransition::new(Vc::upcast(
self.client_transition(),
))),
ResolvedVc::upcast(
NextDynamicTransition::new(Vc::upcast(self.client_transition()))
.to_resolved()
.await?,
),
)]
.into_iter()
.collect(),
..Default::default()
}
.cell()
.cell())
}

#[turbo_tasks::function]
Expand Down
15 changes: 12 additions & 3 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,10 @@ impl Project {
if let Some(app_project) = app_project {
transitions.push((
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
app_project.edge_client_reference_transition(),
app_project
.edge_client_reference_transition()
.to_resolved()
.await?,
));
}

Expand Down Expand Up @@ -1025,7 +1028,10 @@ impl Project {
if let Some(app_project) = app_project {
transitions.push((
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
app_project.client_reference_transition(),
app_project
.client_reference_transition()
.to_resolved()
.await?,
));
}

Expand Down Expand Up @@ -1075,7 +1081,10 @@ impl Project {
if let Some(app_project) = app_project {
transitions.push((
ECMASCRIPT_CLIENT_TRANSITION_NAME.into(),
app_project.edge_client_reference_transition(),
app_project
.edge_client_reference_transition()
.to_resolved()
.await?,
));
}

Expand Down
Loading
Loading