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

turbopack: Chunking Refactor Step 2 #56504

Merged
merged 7 commits into from Oct 6, 2023
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
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
Expand Up @@ -40,11 +40,11 @@ swc_core = { version = "0.83.28", features = [
testing = { version = "0.34.1" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231005.2" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231006.1" }
# [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-231005.2" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231006.1" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231005.2" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231006.1" }

# General Deps

Expand Down
14 changes: 9 additions & 5 deletions packages/next-swc/crates/next-api/src/app.rs
Expand Up @@ -39,8 +39,9 @@ use turbopack_binding::{
turbopack::{
core::{
asset::{Asset, AssetContent},
chunk::{ChunkableModuleExt, ChunkingContext, EvaluatableAssets},
chunk::{ChunkingContext, EvaluatableAssets},
file_source::FileSource,
module::Module,
output::{OutputAsset, OutputAssets},
virtual_output::VirtualOutputAsset,
},
Expand Down Expand Up @@ -507,7 +508,13 @@ impl AppEndpoint {
let mut server_assets = vec![];
let mut client_assets = vec![];

let app_entry = app_entry.await?;

let client_shared_chunks = get_app_client_shared_chunks(
app_entry
.rsc_entry
.ident()
.with_modifier(Vc::cell("client_shared_chunks".to_string())),
this.app_project.client_runtime_entries(),
this.app_project.project().client_chunking_context(),
);
Expand All @@ -524,7 +531,6 @@ impl AppEndpoint {
}
}

let app_entry = app_entry.await?;
let rsc_entry = app_entry.rsc_entry;

let rsc_entry_asset = Vc::upcast(rsc_entry);
Expand Down Expand Up @@ -707,9 +713,7 @@ impl AppEndpoint {
}

let files = chunking_context.evaluated_chunk_group(
app_entry
.rsc_entry
.as_root_chunk(Vc::upcast(chunking_context)),
app_entry.rsc_entry.ident(),
Vc::cell(evaluatable_assets),
);
server_assets.extend(files.await?.iter().copied());
Expand Down
8 changes: 3 additions & 5 deletions packages/next-swc/crates/next-api/src/middleware.rs
Expand Up @@ -13,7 +13,7 @@ use turbopack_binding::{
turbopack::{
core::{
asset::AssetContent,
chunk::{ChunkableModuleExt, ChunkingContext},
chunk::ChunkingContext,
context::AssetContext,
module::Module,
output::{OutputAsset, OutputAssets},
Expand Down Expand Up @@ -88,10 +88,8 @@ impl MiddlewareEndpoint {

let edge_chunking_context = self.project.edge_middleware_chunking_context();

let edge_files = edge_chunking_context.evaluated_chunk_group(
module.as_root_chunk(Vc::upcast(edge_chunking_context)),
Vc::cell(evaluatable_assets),
);
let edge_files = edge_chunking_context
.evaluated_chunk_group(module.ident(), Vc::cell(evaluatable_assets));

Ok(edge_files)
}
Expand Down