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

Add client_root for edge #7081

Merged
merged 3 commits into from
Jan 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/turbopack-cli/src/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ async fn source(
let build_chunking_context = DevChunkingContext::builder(
project_path,
build_output_root,
build_output_root,
build_output_root.join("chunks".to_string()),
build_output_root.join("assets".to_string()),
node_build_environment(),
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-cli/src/dev/web_entry_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub fn get_client_chunking_context(
DevChunkingContext::builder(
project_path,
server_root,
server_root,
server_root.join("/_chunks".to_string()),
server_root.join("/_assets".to_string()),
environment,
Expand Down
10 changes: 7 additions & 3 deletions crates/turbopack-dev/src/chunking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ pub struct DevChunkingContext {
/// This path get stripped off of chunk paths before generating output asset
/// paths.
context_path: Vc<FileSystemPath>,
/// This path is used to compute the url to request chunks or assets from
/// This path is used to compute the url to request chunks from
output_root: Vc<FileSystemPath>,
/// This path is used to compute the url to request assets from
client_root: Vc<FileSystemPath>,
/// Chunks are placed at this path
chunk_root_path: Vc<FileSystemPath>,
/// Chunks reference source maps assets
Expand All @@ -105,6 +107,7 @@ impl DevChunkingContext {
pub fn builder(
context_path: Vc<FileSystemPath>,
output_root: Vc<FileSystemPath>,
client_root: Vc<FileSystemPath>,
chunk_root_path: Vc<FileSystemPath>,
asset_root_path: Vc<FileSystemPath>,
environment: Vc<Environment>,
Expand All @@ -113,6 +116,7 @@ impl DevChunkingContext {
chunking_context: DevChunkingContext {
context_path,
output_root,
client_root,
chunk_root_path,
reference_chunk_source_maps: true,
reference_css_chunk_source_maps: true,
Expand Down Expand Up @@ -235,8 +239,8 @@ impl ChunkingContext for DevChunkingContext {
let this = self.await?;
let asset_path = ident.path().await?.to_string();
let asset_path = asset_path
.strip_prefix(&format!("{}/", this.output_root.await?.path))
.context("expected output_root to contain asset path")?;
.strip_prefix(&format!("{}/", this.client_root.await?.path))
.context("expected asset_path to contain client_root")?;

Ok(Vc::cell(format!(
"{}{}",
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-tests/tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ async fn run_test(prepared_test: Vc<PreparedTest>) -> Result<Vc<RunTestResult>>
let chunking_context = DevChunkingContext::builder(
project_root,
chunk_root_path,
static_root_path,
chunk_root_path,
static_root_path,
env,
Expand Down
13 changes: 10 additions & 3 deletions crates/turbopack-tests/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,16 @@ async fn run_test(resource: String) -> Result<Vc<FileSystemPath>> {

let chunking_context: Vc<Box<dyn ChunkingContext>> = match options.runtime {
Runtime::Dev => Vc::upcast(
DevChunkingContext::builder(project_root, path, chunk_root_path, static_root_path, env)
.runtime_type(options.runtime_type)
.build(),
DevChunkingContext::builder(
project_root,
path,
path,
chunk_root_path,
static_root_path,
env,
)
.runtime_type(options.runtime_type)
.build(),
),
Runtime::Build => Vc::upcast(
BuildChunkingContext::builder(
Expand Down