Skip to content

Commit 18547d5

Browse files
authored
add support for assets in edge (#63209)
### What? add support for `new URL(..., import.meta.url)` assets in edge. e. g. needed for og-image. ### Why? ### Turbopack Changes * vercel/turborepo#7712 <!-- Tobias Koppers - allow to use full urls in browser runtime --> Closes PACK-2725
1 parent 11af8dd commit 18547d5

File tree

15 files changed

+132
-77
lines changed

15 files changed

+132
-77
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ swc_core = { version = "0.90.17", features = [
3737
testing = { version = "0.35.20" }
3838

3939
# Turbo crates
40-
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.4" }
40+
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.5" }
4141
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
42-
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.4" }
42+
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.5" }
4343
# [TODO]: need to refactor embed_directory! macro usage in next-core
44-
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.4" }
44+
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240312.5" }
4545

4646
# General Deps
4747

packages/next-swc/crates/next-api/src/app.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,18 +519,19 @@ impl AppEndpoint {
519519
async fn output(self: Vc<Self>) -> Result<Vc<AppEndpointOutput>> {
520520
let this = self.await?;
521521

522-
let (app_entry, process_client, process_ssr) = match this.ty {
522+
let (app_entry, process_client, process_ssr, has_client_side_assets) = match this.ty {
523523
AppEndpointType::Page { ty, loader_tree } => (
524524
self.app_page_entry(loader_tree),
525525
true,
526526
matches!(ty, AppPageEndpointType::Html),
527+
true,
527528
),
528529
// NOTE(alexkirsz) For routes, technically, a lot of the following code is not needed,
529530
// as we know we won't have any client references. However, for now, for simplicity's
530531
// sake, we just do the same thing as for pages.
531-
AppEndpointType::Route { path } => (self.app_route_entry(path), false, false),
532+
AppEndpointType::Route { path } => (self.app_route_entry(path), false, false, false),
532533
AppEndpointType::Metadata { metadata } => {
533-
(self.app_metadata_entry(metadata), false, false)
534+
(self.app_metadata_entry(metadata), false, false, false)
534535
}
535536
};
536537

@@ -613,7 +614,10 @@ impl AppEndpoint {
613614
NextRuntime::NodeJs => {
614615
Vc::upcast(this.app_project.project().server_chunking_context())
615616
}
616-
NextRuntime::Edge => this.app_project.project().edge_chunking_context(),
617+
NextRuntime::Edge => this
618+
.app_project
619+
.project()
620+
.edge_chunking_context(has_client_side_assets),
617621
})
618622
} else {
619623
None
@@ -837,7 +841,10 @@ impl AppEndpoint {
837841
let endpoint_output = match runtime {
838842
NextRuntime::Edge => {
839843
// create edge chunks
840-
let chunking_context = this.app_project.project().edge_chunking_context();
844+
let chunking_context = this
845+
.app_project
846+
.project()
847+
.edge_chunking_context(has_client_side_assets);
841848
let mut evaluatable_assets = this
842849
.app_project
843850
.edge_rsc_runtime_entries()

packages/next-swc/crates/next-api/src/instrumentation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl InstrumentationEndpoint {
9595
};
9696
evaluatable_assets.push(evaluatable);
9797

98-
let edge_chunking_context = self.project.edge_chunking_context();
98+
let edge_chunking_context = self.project.edge_chunking_context(false);
9999

100100
let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
101101
module.ident(),

packages/next-swc/crates/next-api/src/middleware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl MiddlewareEndpoint {
9797
.context("Entry module must be evaluatable")?;
9898
evaluatable_assets.push(evaluatable);
9999

100-
let edge_chunking_context = self.project.edge_chunking_context();
100+
let edge_chunking_context = self.project.edge_chunking_context(true);
101101

102102
let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
103103
module.ident(),

0 commit comments

Comments
 (0)