Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
40ac0bbd
Commit
40ac0bbd
authored
Feb 24, 2026
by
Matt Mastracci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added chunk_item on ChunkingContext
parent
d21aef63
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
25 deletions
+65
-25
server_actions.rs
crates/next-api/src/server_actions.rs
+2
-2
hmr_entry.rs
crates/next-core/src/hmr_entry.rs
+3
-3
ecmascript_client_reference_module.rs
...pt_client_reference/ecmascript_client_reference_module.rs
+5
-4
chunking_context.rs
turbopack/crates/turbopack-browser/src/chunking_context.rs
+5
-5
chunk_item_batch.rs
...opack/crates/turbopack-core/src/chunk/chunk_item_batch.rs
+6
-3
chunking_context.rs
...opack/crates/turbopack-core/src/chunk/chunking_context.rs
+36
-1
asset.rs
turbopack/crates/turbopack-css/src/asset.rs
+3
-3
chunking_context.rs
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
+5
-4
No files found.
crates/next-api/src/server_actions.rs
View file @
40ac0bbd
...
@@ -27,7 +27,7 @@ use turbo_tasks_fs::{self, File, FileContent, FileSystemPath, rope::RopeBuilder}
...
@@ -27,7 +27,7 @@ use turbo_tasks_fs::{self, File, FileContent, FileSystemPath, rope::RopeBuilder}
use
turbopack_core
::{
use
turbopack_core
::{
asset
::
AssetContent
,
asset
::
AssetContent
,
chunk
::{
chunk
::{
ChunkItem
,
ChunkItemExt
,
Chunk
ableModule
,
ChunkingConte
xt
,
EvaluatableAsset
,
ModuleId
,
ChunkItem
,
ChunkItemExt
,
Chunk
ingContext
,
ChunkingContextE
xt
,
EvaluatableAsset
,
ModuleId
,
},
},
context
::
AssetContext
,
context
::
AssetContext
,
file_source
::
FileSource
,
file_source
::
FileSource
,
...
@@ -78,7 +78,7 @@ pub(crate) async fn create_server_actions_manifest(
...
@@ -78,7 +78,7 @@ pub(crate) async fn create_server_actions_manifest(
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
EvaluatableAsset
>>
(
loader
.to_resolved
()
.await
?
)
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
EvaluatableAsset
>>
(
loader
.to_resolved
()
.await
?
)
.context
(
"loader module must be evaluatable"
)
?
;
.context
(
"loader module must be evaluatable"
)
?
;
let
chunk_item
=
loader
.as_chunk_item
(
module_graph
,
chunking_context
);
let
chunk_item
=
chunking_context
.chunk_item
(
Vc
::
upcast
(
loader
),
module_graph
);
let
manifest
=
build_manifest
(
let
manifest
=
build_manifest
(
node_root
,
node_root
,
page_name
,
page_name
,
...
...
crates/next-core/src/hmr_entry.rs
View file @
40ac0bbd
...
@@ -7,8 +7,8 @@ use turbo_tasks_fs::{FileSystem, VirtualFileSystem, rope::RopeBuilder};
...
@@ -7,8 +7,8 @@ use turbo_tasks_fs::{FileSystem, VirtualFileSystem, rope::RopeBuilder};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
chunk
::{
AsyncModuleInfo
,
ChunkableModule
,
ChunkingContext
,
Chunking
Type
,
ChunkingTypeOption
,
AsyncModuleInfo
,
ChunkableModule
,
ChunkingContext
,
Chunking
ContextExt
,
ChunkingType
,
EvaluatableAsset
,
ChunkingTypeOption
,
EvaluatableAsset
,
},
},
ident
::
AssetIdent
,
ident
::
AssetIdent
,
module
::{
Module
,
ModuleSideEffects
},
module
::{
Module
,
ModuleSideEffects
},
...
@@ -108,7 +108,7 @@ impl EcmascriptChunkPlaceable for HmrEntryModule {
...
@@ -108,7 +108,7 @@ impl EcmascriptChunkPlaceable for HmrEntryModule {
)
->
Result
<
Vc
<
EcmascriptChunkItemContent
>>
{
)
->
Result
<
Vc
<
EcmascriptChunkItemContent
>>
{
let
this
=
self
.await
?
;
let
this
=
self
.await
?
;
let
module
=
this
.module
;
let
module
=
this
.module
;
let
chunk_item
=
module
.as_chunk_item
(
module_graph
,
chunking_context
);
let
chunk_item
=
chunking_context
.chunk_item
(
Vc
::
upcast
(
*
module
),
module_graph
);
let
id
=
chunking_context
let
id
=
chunking_context
.chunk_item_id_strategy
()
.chunk_item_id_strategy
()
.await
?
.await
?
...
...
crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_module.rs
View file @
40ac0bbd
...
@@ -9,7 +9,7 @@ use turbopack_core::{
...
@@ -9,7 +9,7 @@ use turbopack_core::{
asset
::
AssetContent
,
asset
::
AssetContent
,
chunk
::{
chunk
::{
AsyncModuleInfo
,
ChunkGroupType
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingContext
,
AsyncModuleInfo
,
ChunkGroupType
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingContext
,
ChunkingType
,
ChunkingTypeOption
,
Chunking
ContextExt
,
Chunking
Type
,
ChunkingTypeOption
,
},
},
code_builder
::
CodeBuilder
,
code_builder
::
CodeBuilder
,
context
::
AssetContext
,
context
::
AssetContext
,
...
@@ -257,9 +257,10 @@ impl ChunkableModule for EcmascriptClientReferenceModule {
...
@@ -257,9 +257,10 @@ impl ChunkableModule for EcmascriptClientReferenceModule {
module_graph
:
Vc
<
ModuleGraph
>
,
module_graph
:
Vc
<
ModuleGraph
>
,
chunking_context
:
ResolvedVc
<
Box
<
dyn
ChunkingContext
>>
,
chunking_context
:
ResolvedVc
<
Box
<
dyn
ChunkingContext
>>
,
)
->
Result
<
Vc
<
Box
<
dyn
ChunkItem
>>>
{
)
->
Result
<
Vc
<
Box
<
dyn
ChunkItem
>>>
{
let
item
=
self
let
item
=
chunking_context
.chunk_item
(
.proxy_module
()
Vc
::
upcast
(
self
.proxy_module
()),
.as_chunk_item
(
module_graph
,
*
chunking_context
);
module_graph
,
);
let
ecmascript_item
=
let
ecmascript_item
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
EcmascriptChunkItem
>>
(
item
.to_resolved
()
.await
?
)
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
EcmascriptChunkItem
>>
(
item
.to_resolved
()
.await
?
)
.context
(
"EcmascriptModuleAsset must implement EcmascriptChunkItem"
)
?
;
.context
(
"EcmascriptModuleAsset must implement EcmascriptChunkItem"
)
?
;
...
...
turbopack/crates/turbopack-browser/src/chunking_context.rs
View file @
40ac0bbd
...
@@ -12,9 +12,9 @@ use turbopack_core::{
...
@@ -12,9 +12,9 @@ use turbopack_core::{
asset
::
Asset
,
asset
::
Asset
,
chunk
::{
chunk
::{
AssetSuffix
,
Chunk
,
ChunkGroupResult
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
AssetSuffix
,
Chunk
,
ChunkGroupResult
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingConfig
,
ChunkingConfigs
,
ChunkingContext
,
EntryChunkGroupResult
,
EvaluatableAsse
t
,
ChunkingConfig
,
ChunkingConfigs
,
ChunkingContext
,
ChunkingContextEx
t
,
E
valuatableAssets
,
MinifyType
,
SourceMapSourceType
,
SourceMapsType
,
UnusedReferences
,
E
ntryChunkGroupResult
,
EvaluatableAsset
,
EvaluatableAssets
,
MinifyType
,
UrlBehavior
,
SourceMapSourceType
,
SourceMapsType
,
UnusedReferences
,
UrlBehavior
,
availability_info
::
AvailabilityInfo
,
availability_info
::
AvailabilityInfo
,
chunk_group
::{
MakeChunkGroupResult
,
make_chunk_group
},
chunk_group
::{
MakeChunkGroupResult
,
make_chunk_group
},
chunk_id_strategy
::
ModuleIdStrategy
,
chunk_id_strategy
::
ModuleIdStrategy
,
...
@@ -917,10 +917,10 @@ impl ChunkingContext for BrowserChunkingContext {
...
@@ -917,10 +917,10 @@ impl ChunkingContext for BrowserChunkingContext {
availability_info
,
availability_info
,
);
);
let
loader_module
=
ManifestLoaderModule
::
new
(
manifest_asset
);
let
loader_module
=
ManifestLoaderModule
::
new
(
manifest_asset
);
loader_module
.as_chunk_item
(
module_graph
,
*
chunking_context
)
chunking_context
.chunk_item
(
Vc
::
upcast
(
loader_module
),
module_graph
)
}
else
{
}
else
{
let
module
=
AsyncLoaderModule
::
new
(
module
,
*
chunking_context
,
availability_info
);
let
module
=
AsyncLoaderModule
::
new
(
module
,
*
chunking_context
,
availability_info
);
module
.as_chunk_item
(
module_graph
,
*
chunking_context
)
chunking_context
.chunk_item
(
Vc
::
upcast
(
module
),
module_graph
)
})
})
}
}
...
...
turbopack/crates/turbopack-core/src/chunk/chunk_item_batch.rs
View file @
40ac0bbd
...
@@ -11,7 +11,10 @@ use turbo_tasks::{
...
@@ -11,7 +11,10 @@ use turbo_tasks::{
};
};
use
crate
::{
use
crate
::{
chunk
::{
ChunkItem
,
ChunkItemWithAsyncModuleInfo
,
ChunkType
,
ChunkableModule
,
ChunkingContext
},
chunk
::{
ChunkItem
,
ChunkItemWithAsyncModuleInfo
,
ChunkType
,
ChunkableModule
,
ChunkingContext
,
chunking_context
::
ChunkingContextExt
,
},
module_graph
::{
module_graph
::{
ModuleGraph
,
ModuleGraph
,
async_module_info
::
AsyncModulesInfo
,
async_module_info
::
AsyncModulesInfo
,
...
@@ -37,8 +40,8 @@ pub async fn attach_async_info_to_chunkable_module(
...
@@ -37,8 +40,8 @@ pub async fn attach_async_info_to_chunkable_module(
}
else
{
}
else
{
None
None
};
};
let
chunk_item
=
module
let
chunk_item
=
chunking_context
.
as_chunk_item
(
module_graph
,
chunking_context
)
.
chunk_item
(
Vc
::
upcast
(
*
module
),
module_graph
)
.to_resolved
()
.to_resolved
()
.await
?
;
.await
?
;
Ok
(
ChunkItemWithAsyncModuleInfo
{
Ok
(
ChunkItemWithAsyncModuleInfo
{
...
...
turbopack/crates/turbopack-core/src/chunk/chunking_context.rs
View file @
40ac0bbd
...
@@ -3,7 +3,9 @@ use bincode::{Decode, Encode};
...
@@ -3,7 +3,9 @@ use bincode::{Decode, Encode};
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
NonLocalValue
,
ResolvedVc
,
TaskInput
,
Upcast
,
Vc
,
trace
::
TraceRawVcs
};
use
turbo_tasks
::{
NonLocalValue
,
ResolvedVc
,
TaskInput
,
Upcast
,
ValueToString
,
Vc
,
trace
::
TraceRawVcs
,
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_hash
::
DeterministicHash
;
use
turbo_tasks_hash
::
DeterministicHash
;
...
@@ -578,6 +580,15 @@ pub trait ChunkingContextExt {
...
@@ -578,6 +580,15 @@ pub trait ChunkingContextExt {
fn
relative_path_from_chunk_root_to_project_root
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
fn
relative_path_from_chunk_root_to_project_root
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
where
where
Self
:
Send
;
Self
:
Send
;
/// Creates a chunk item from a module. The module must implement `ChunkableModule`.
fn
chunk_item
(
self
:
Vc
<
Self
>
,
module
:
Vc
<
Box
<
dyn
Module
>>
,
module_graph
:
Vc
<
ModuleGraph
>
,
)
->
Vc
<
Box
<
dyn
ChunkItem
>>
where
Self
:
Send
;
}
}
impl
<
T
:
ChunkingContext
+
Send
+
Upcast
<
Box
<
dyn
ChunkingContext
>>>
ChunkingContextExt
for
T
{
impl
<
T
:
ChunkingContext
+
Send
+
Upcast
<
Box
<
dyn
ChunkingContext
>>>
ChunkingContextExt
for
T
{
...
@@ -696,6 +707,30 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
...
@@ -696,6 +707,30 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
fn
relative_path_from_chunk_root_to_project_root
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
fn
relative_path_from_chunk_root_to_project_root
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
relative_path_from_chunk_root_to_project_root
(
Vc
::
upcast_non_strict
(
self
))
relative_path_from_chunk_root_to_project_root
(
Vc
::
upcast_non_strict
(
self
))
}
}
fn
chunk_item
(
self
:
Vc
<
Self
>
,
module
:
Vc
<
Box
<
dyn
Module
>>
,
module_graph
:
Vc
<
ModuleGraph
>
,
)
->
Vc
<
Box
<
dyn
ChunkItem
>>
{
chunk_item
(
Vc
::
upcast_non_strict
(
self
),
module
,
module_graph
)
}
}
#[turbo_tasks
::
function]
async
fn
chunk_item
(
chunking_context
:
Vc
<
Box
<
dyn
ChunkingContext
>>
,
module
:
Vc
<
Box
<
dyn
Module
>>
,
module_graph
:
Vc
<
ModuleGraph
>
,
)
->
Result
<
Vc
<
Box
<
dyn
ChunkItem
>>>
{
let
module
=
module
.to_resolved
()
.await
?
;
let
Some
(
chunkable
)
=
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
module
)
else
{
bail!
(
"Module {} is not chunkable"
,
module
.ident
()
.to_string
()
.await
?
);
};
Ok
(
chunkable
.as_chunk_item
(
module_graph
,
chunking_context
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-css/src/asset.rs
View file @
40ac0bbd
...
@@ -3,7 +3,7 @@ use turbo_rcstr::rcstr;
...
@@ -3,7 +3,7 @@ use turbo_rcstr::rcstr;
use
turbo_tasks
::{
IntoTraitRef
,
ResolvedVc
,
TryJoinIterExt
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
IntoTraitRef
,
ResolvedVc
,
TryJoinIterExt
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::{
FileContent
,
FileSystemPath
};
use
turbo_tasks_fs
::{
FileContent
,
FileSystemPath
};
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingContext
,
MinifyType
},
chunk
::{
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingContext
,
ChunkingContextExt
,
MinifyType
},
context
::
AssetContext
,
context
::
AssetContext
,
environment
::
Environment
,
environment
::
Environment
,
ident
::
AssetIdent
,
ident
::
AssetIdent
,
...
@@ -276,7 +276,7 @@ impl CssChunkItem for CssModuleChunkItem {
...
@@ -276,7 +276,7 @@ impl CssChunkItem for CssModuleChunkItem {
if
let
Some
(
placeable
)
=
if
let
Some
(
placeable
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkPlaceable
>>
(
module
)
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkPlaceable
>>
(
module
)
{
{
let
item
=
placeable
.as_chunk_item
(
*
self
.module_graph
,
*
chunking_context
);
let
item
=
chunking_context
.chunk_item
(
Vc
::
upcast
(
*
placeable
),
*
self
.module_graph
);
if
let
Some
(
css_item
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkItem
>>
(
if
let
Some
(
css_item
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkItem
>>
(
item
.to_resolved
()
.await
?
,
item
.to_resolved
()
.await
?
,
)
{
)
{
...
@@ -298,7 +298,7 @@ impl CssChunkItem for CssModuleChunkItem {
...
@@ -298,7 +298,7 @@ impl CssChunkItem for CssModuleChunkItem {
if
let
Some
(
placeable
)
=
if
let
Some
(
placeable
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkPlaceable
>>
(
module
)
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkPlaceable
>>
(
module
)
{
{
let
item
=
placeable
.as_chunk_item
(
*
self
.module_graph
,
*
chunking_context
);
let
item
=
chunking_context
.chunk_item
(
Vc
::
upcast
(
*
placeable
),
*
self
.module_graph
);
if
let
Some
(
css_item
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkItem
>>
(
if
let
Some
(
css_item
)
=
ResolvedVc
::
try_downcast
::
<
Box
<
dyn
CssChunkItem
>>
(
item
.to_resolved
()
.await
?
,
item
.to_resolved
()
.await
?
,
)
{
)
{
...
...
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
View file @
40ac0bbd
...
@@ -7,8 +7,9 @@ use turbopack_core::{
...
@@ -7,8 +7,9 @@ use turbopack_core::{
asset
::
Asset
,
asset
::
Asset
,
chunk
::{
chunk
::{
AssetSuffix
,
Chunk
,
ChunkGroupResult
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
AssetSuffix
,
Chunk
,
ChunkGroupResult
,
ChunkItem
,
ChunkType
,
ChunkableModule
,
ChunkingConfig
,
ChunkingConfigs
,
ChunkingContext
,
EntryChunkGroupResult
,
EvaluatableAssets
,
ChunkingConfig
,
ChunkingConfigs
,
ChunkingContext
,
ChunkingContextExt
,
MinifyType
,
SourceMapSourceType
,
SourceMapsType
,
UnusedReferences
,
UrlBehavior
,
EntryChunkGroupResult
,
EvaluatableAssets
,
MinifyType
,
SourceMapSourceType
,
SourceMapsType
,
UnusedReferences
,
UrlBehavior
,
availability_info
::
AvailabilityInfo
,
availability_info
::
AvailabilityInfo
,
chunk_group
::{
MakeChunkGroupResult
,
make_chunk_group
},
chunk_group
::{
MakeChunkGroupResult
,
make_chunk_group
},
chunk_id_strategy
::
ModuleIdStrategy
,
chunk_id_strategy
::
ModuleIdStrategy
,
...
@@ -653,10 +654,10 @@ impl ChunkingContext for NodeJsChunkingContext {
...
@@ -653,10 +654,10 @@ impl ChunkingContext for NodeJsChunkingContext {
.to_resolved
()
.to_resolved
()
.await
?
;
.await
?
;
let
loader_module
=
ManifestLoaderModule
::
new
(
*
manifest_asset
);
let
loader_module
=
ManifestLoaderModule
::
new
(
*
manifest_asset
);
loader_module
.as_chunk_item
(
module_graph
,
*
chunking_context
)
chunking_context
.chunk_item
(
Vc
::
upcast
(
loader_module
),
module_graph
)
}
else
{
}
else
{
let
module
=
AsyncLoaderModule
::
new
(
module
,
*
chunking_context
,
availability_info
);
let
module
=
AsyncLoaderModule
::
new
(
module
,
*
chunking_context
,
availability_info
);
module
.as_chunk_item
(
module_graph
,
*
chunking_context
)
chunking_context
.chunk_item
(
Vc
::
upcast
(
module
),
module_graph
)
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment