-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description Next.js side: vercel/next.js#47961 Previous episode: #4397 In this episode, we: 1. Get rid of `ChunkGroupVc`. `ChunkGroupVc` previously took care of: a. optimizing chunks; b. adding additional chunks, such as the "evaluate" chunk, which evaluates runtime entries. Both of these use cases are a concern of the chunking context (i.e. it would differ between dev and build), hence they're now handled by the chunking context. 2. Move the chunk list registration logic into a different chunk. The chunk list was previously a bit leaky as it required the Next.js code to instantiate it manually. There were also a bunch of other instantiations in the code which differed ever so slightly. The chunk list registration code is now part of a separate chunk, which is only added by the dev chunking context. ### Testing Instructions Snapshots + Next dev tests + Manual tests fix WEB-822
- Loading branch information
Showing
150 changed files
with
1,938 additions
and
1,553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::fmt::Debug; | ||
|
||
use anyhow::Result; | ||
use turbo_tasks::primitives::{BoolVc, StringVc}; | ||
use turbo_tasks_fs::FileSystemPathVc; | ||
|
||
use super::{ChunkVc, EvaluatableAssetsVc}; | ||
use crate::{ | ||
asset::{AssetVc, AssetsVc}, | ||
environment::EnvironmentVc, | ||
ident::AssetIdentVc, | ||
}; | ||
|
||
/// A context for the chunking that influences the way chunks are created | ||
#[turbo_tasks::value_trait] | ||
pub trait ChunkingContext { | ||
fn context_path(&self) -> FileSystemPathVc; | ||
fn output_root(&self) -> FileSystemPathVc; | ||
|
||
// TODO remove this, a chunking context should not be bound to a specific | ||
// environment since this can change due to transitions in the module graph | ||
fn environment(&self) -> EnvironmentVc; | ||
|
||
// TODO(alexkirsz) Remove this from the chunking context. This should be at the | ||
// discretion of chunking context implementors. However, we currently use this | ||
// in a couple of places in `turbopack-css`, so we need to remove that | ||
// dependency first. | ||
fn chunk_path(&self, ident: AssetIdentVc, extension: &str) -> FileSystemPathVc; | ||
|
||
// TODO(alexkirsz) Remove this from the chunking context. | ||
/// Reference Source Map Assets for chunks | ||
fn reference_chunk_source_maps(&self, chunk: AssetVc) -> BoolVc; | ||
|
||
fn can_be_in_same_chunk(&self, asset_a: AssetVc, asset_b: AssetVc) -> BoolVc; | ||
|
||
fn asset_path(&self, content_hash: &str, extension: &str) -> FileSystemPathVc; | ||
|
||
fn is_hot_module_replacement_enabled(&self) -> BoolVc { | ||
BoolVc::cell(false) | ||
} | ||
|
||
fn layer(&self) -> StringVc { | ||
StringVc::cell("".to_string()) | ||
} | ||
|
||
fn with_layer(&self, layer: &str) -> ChunkingContextVc; | ||
|
||
fn chunk_group(&self, entry: ChunkVc) -> AssetsVc; | ||
|
||
fn evaluated_chunk_group( | ||
&self, | ||
entry: ChunkVc, | ||
evaluatable_assets: EvaluatableAssetsVc, | ||
) -> AssetsVc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.