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

Lazy DevHtmlAsset chunk generation #48768

Merged
merged 2 commits into from Apr 24, 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
64 changes: 32 additions & 32 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 @@ -42,11 +42,11 @@ swc_relay = { version = "0.2.5" }
testing = { version = "0.33.4" }

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

# General Deps

Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/js/package.json
Expand Up @@ -10,8 +10,8 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230420.2",
"@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230420.2",
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230424.2",
"@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230424.2",
"anser": "^2.1.1",
"css.escape": "^1.5.1",
"next": "*",
Expand Down
8 changes: 4 additions & 4 deletions packages/next-swc/crates/next-core/src/fallback.rs
Expand Up @@ -5,7 +5,6 @@ use turbo_binding::{
turbo::{tasks_env::ProcessEnvVc, tasks_fs::FileSystemPathVc},
turbopack::{
core::{
chunk::{ChunkableAsset, ChunkingContext},
compile_time_info::CompileTimeInfoVc,
context::AssetContextVc,
resolve::{options::ImportMap, origin::PlainResolveOriginVc},
Expand Down Expand Up @@ -85,9 +84,10 @@ pub async fn get_fallback_page(

Ok(DevHtmlAssetVc::new(
dev_server_root.join("fallback.html"),
vec![chunking_context.evaluated_chunk_group(
module.as_root_chunk(chunking_context),
runtime_entries.with_entry(module.into()),
vec![(
module.into(),
chunking_context,
Some(runtime_entries.with_entry(module.into())),
)],
))
}
18 changes: 9 additions & 9 deletions packages/next-swc/crates/next-core/src/web_entry_source.rs
Expand Up @@ -6,7 +6,7 @@ use turbo_binding::{
},
turbopack::{
core::{
chunk::{ChunkableAsset, ChunkableAssetVc, ChunkingContext},
chunk::ChunkableAssetVc,
compile_time_defines,
compile_time_info::{
CompileTimeDefines, CompileTimeDefinesVc, CompileTimeInfo, CompileTimeInfoVc,
Expand Down Expand Up @@ -156,20 +156,20 @@ pub async fn create_web_entry_source(
.try_join()
.await?;

let chunk_groups: Vec<_> = entries
let entries: Vec<_> = entries
.into_iter()
.flatten()
.map(|module| async move {
if let Some(ecmascript) = EcmascriptModuleAssetVc::resolve_from(module).await? {
let chunk_group = chunking_context.evaluated_chunk_group(
ecmascript.as_root_chunk(chunking_context),
runtime_entries.with_entry(ecmascript.into()),
);
Ok(chunk_group)
Ok((
ecmascript.into(),
chunking_context,
Some(runtime_entries.with_entry(ecmascript.into())),
))
} else if let Some(chunkable) = ChunkableAssetVc::resolve_from(module).await? {
// TODO this is missing runtime code, so it's probably broken and we should also
// add an ecmascript chunk with the runtime code
Ok(chunking_context.chunk_group(chunkable.as_root_chunk(chunking_context)))
Ok((chunkable, chunking_context, None))
} else {
// TODO convert into a serve-able asset
Err(anyhow!(
Expand All @@ -181,7 +181,7 @@ pub async fn create_web_entry_source(
.try_join()
.await?;

let entry_asset = DevHtmlAssetVc::new(server_root.join("index.html"), chunk_groups).into();
let entry_asset = DevHtmlAssetVc::new(server_root.join("index.html"), entries).into();

let graph = if eager_compile {
AssetGraphContentSourceVc::new_eager(server_root, entry_asset)
Expand Down