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

Make get_client_chunking_context independent of context #51928

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions packages/next-swc/crates/next-core/src/app_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ async fn next_client_transition(
project_path,
server_root,
client_compile_time_info.environment(),
ty,
);
let client_module_options_context = get_client_module_options_context(
project_path,
Expand Down Expand Up @@ -277,7 +276,7 @@ fn next_edge_route_transition(
project_path,
output_path.join("edge"),
output_path.join("edge/chunks"),
get_client_assets_path(server_root, Value::new(ClientContextType::App { app_dir })),
get_client_assets_path(server_root),
edge_compile_time_info.environment(),
)
.reference_chunk_source_maps(should_debug("app_source"))
Expand Down Expand Up @@ -317,7 +316,7 @@ fn next_edge_page_transition(
project_path,
output_path.join("edge-pages"),
output_path.join("edge-pages/chunks"),
get_client_assets_path(server_root, Value::new(ClientContextType::App { app_dir })),
get_client_assets_path(server_root),
edge_compile_time_info.environment(),
)
.layer("ssr")
Expand Down Expand Up @@ -1112,7 +1111,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
project_path,
intermediate_output_path,
intermediate_output_path.join("chunks"),
get_client_assets_path(server_root, Value::new(ClientContextType::App { app_dir })),
get_client_assets_path(server_root),
context.compile_time_info().environment(),
)
.layer("ssr")
Expand Down Expand Up @@ -1207,12 +1206,7 @@ impl AppRouteVc {
this.project_path,
this.intermediate_output_path,
this.intermediate_output_path.join("chunks"),
get_client_assets_path(
this.server_root,
Value::new(ClientContextType::App {
app_dir: this.app_dir,
}),
),
get_client_assets_path(this.server_root),
this.context.compile_time_info().environment(),
)
.layer("ssr")
Expand Down
1 change: 0 additions & 1 deletion packages/next-swc/crates/next-core/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub async fn get_fallback_page(
project_path,
dev_server_root,
client_compile_time_info.environment(),
ty,
);
let entries =
get_client_runtime_entries(project_path, env, ty, mode, next_config, execution_context);
Expand Down
26 changes: 6 additions & 20 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,37 +312,23 @@ pub fn get_client_asset_context(
#[turbo_tasks::function]
pub fn get_client_chunking_context(
project_path: FileSystemPathVc,
server_root: FileSystemPathVc,
client_root: FileSystemPathVc,
environment: EnvironmentVc,
ty: Value<ClientContextType>,
) -> ChunkingContextVc {
DevChunkingContextVc::builder(
project_path,
server_root,
match ty.into_value() {
ClientContextType::Pages { .. }
| ClientContextType::App { .. }
| ClientContextType::Fallback => server_root.join("/_next/static/chunks"),
ClientContextType::Other => server_root.join("/_chunks"),
},
get_client_assets_path(server_root, ty),
client_root,
client_root.join("/_next/static/chunks"),
get_client_assets_path(client_root),
environment,
)
.hot_module_replacement()
.build()
}

#[turbo_tasks::function]
pub fn get_client_assets_path(
client_root: FileSystemPathVc,
ty: Value<ClientContextType>,
) -> FileSystemPathVc {
match ty.into_value() {
ClientContextType::Pages { .. }
| ClientContextType::App { .. }
| ClientContextType::Fallback => client_root.join("/_next/static/media"),
ClientContextType::Other => client_root.join("/_assets"),
}
pub fn get_client_assets_path(client_root: FileSystemPathVc) -> FileSystemPathVc {
client_root.join("/_next/static/media")
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl NextClientChunksTransitionVc {
project_path,
server_root,
client_compile_time_info.environment(),
ty,
);

let client_module_options_context = get_client_module_options_context(
Expand Down
23 changes: 4 additions & 19 deletions packages/next-swc/crates/next-core/src/page_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ pub async fn create_page_source(
project_root,
client_root,
client_compile_time_info.environment(),
client_ty,
);

let client_runtime_entries = get_client_runtime_entries(
Expand Down Expand Up @@ -155,10 +154,7 @@ pub async fn create_page_source(
project_root,
node_root.join("edge"),
node_root.join("edge/chunks"),
get_client_assets_path(
client_root,
Value::new(ClientContextType::Pages { pages_dir }),
),
get_client_assets_path(client_root),
edge_compile_time_info.environment(),
)
.reference_chunk_source_maps(should_debug("page_source"))
Expand Down Expand Up @@ -360,10 +356,7 @@ async fn create_page_source_for_file(
project_path,
node_path,
node_path.join("chunks"),
get_client_assets_path(
client_root,
Value::new(ClientContextType::Pages { pages_dir }),
),
get_client_assets_path(client_root),
server_context.compile_time_info().environment(),
)
.reference_chunk_source_maps(should_debug("page_source"))
Expand All @@ -375,10 +368,7 @@ async fn create_page_source_for_file(
project_path,
data_node_path,
data_node_path.join("chunks"),
get_client_assets_path(
client_root,
Value::new(ClientContextType::Pages { pages_dir }),
),
get_client_assets_path(client_root),
server_context.compile_time_info().environment(),
)
.reference_chunk_source_maps(should_debug("page_source"))
Expand All @@ -388,7 +378,6 @@ async fn create_page_source_for_file(
project_path,
client_root,
client_context.compile_time_info().environment(),
Value::new(ClientContextType::Pages { pages_dir }),
);

let pathname = pathname_for_path(client_root, client_path, PathType::Page);
Expand Down Expand Up @@ -530,10 +519,7 @@ async fn create_not_found_page_source(
project_path,
node_path,
node_path.join("chunks"),
get_client_assets_path(
client_root,
Value::new(ClientContextType::Pages { pages_dir }),
),
get_client_assets_path(client_root),
server_context.compile_time_info().environment(),
)
.reference_chunk_source_maps(should_debug("page_source"))
Expand All @@ -543,7 +529,6 @@ async fn create_not_found_page_source(
project_path,
client_root,
client_context.compile_time_info().environment(),
Value::new(ClientContextType::Pages { pages_dir }),
);

let (page_asset, pathname) =
Expand Down
8 changes: 2 additions & 6 deletions packages/next-swc/crates/next-core/src/web_entry_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,8 @@ pub async fn create_web_entry_source(
mode,
next_config,
);
let chunking_context = get_client_chunking_context(
project_root,
client_root,
compile_time_info.environment(),
ty,
);
let chunking_context =
get_client_chunking_context(project_root, client_root, compile_time_info.environment());
let entries = get_web_runtime_entries(project_root, ty, mode, next_config, execution_context);

let runtime_entries = entries.resolve_entries(context);
Expand Down