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 support for assets in edge #63209

Merged
merged 3 commits into from
Mar 12, 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
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ swc_core = { version = "0.90.17", features = [
testing = { version = "0.35.20" }

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

# General Deps

Expand Down
17 changes: 12 additions & 5 deletions packages/next-swc/crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,19 @@ impl AppEndpoint {
async fn output(self: Vc<Self>) -> Result<Vc<AppEndpointOutput>> {
let this = self.await?;

let (app_entry, process_client, process_ssr) = match this.ty {
let (app_entry, process_client, process_ssr, has_client_side_assets) = match this.ty {
AppEndpointType::Page { ty, loader_tree } => (
self.app_page_entry(loader_tree),
true,
matches!(ty, AppPageEndpointType::Html),
true,
),
// NOTE(alexkirsz) For routes, technically, a lot of the following code is not needed,
// as we know we won't have any client references. However, for now, for simplicity's
// sake, we just do the same thing as for pages.
AppEndpointType::Route { path } => (self.app_route_entry(path), false, false),
AppEndpointType::Route { path } => (self.app_route_entry(path), false, false, false),
AppEndpointType::Metadata { metadata } => {
(self.app_metadata_entry(metadata), false, false)
(self.app_metadata_entry(metadata), false, false, false)
}
};

Expand Down Expand Up @@ -613,7 +614,10 @@ impl AppEndpoint {
NextRuntime::NodeJs => {
Vc::upcast(this.app_project.project().server_chunking_context())
}
NextRuntime::Edge => this.app_project.project().edge_chunking_context(),
NextRuntime::Edge => this
.app_project
.project()
.edge_chunking_context(has_client_side_assets),
})
} else {
None
Expand Down Expand Up @@ -837,7 +841,10 @@ impl AppEndpoint {
let endpoint_output = match runtime {
NextRuntime::Edge => {
// create edge chunks
let chunking_context = this.app_project.project().edge_chunking_context();
let chunking_context = this
.app_project
.project()
.edge_chunking_context(has_client_side_assets);
let mut evaluatable_assets = this
.app_project
.edge_rsc_runtime_entries()
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl InstrumentationEndpoint {
};
evaluatable_assets.push(evaluatable);

let edge_chunking_context = self.project.edge_chunking_context();
let edge_chunking_context = self.project.edge_chunking_context(false);

let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
module.ident(),
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl MiddlewareEndpoint {
.context("Entry module must be evaluatable")?;
evaluatable_assets.push(evaluatable);

let edge_chunking_context = self.project.edge_chunking_context();
let edge_chunking_context = self.project.edge_chunking_context(true);

let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
module.ident(),
Expand Down
Loading