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
08dc46f3
Commit
08dc46f3
authored
Jan 27, 2026
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some debugging feedback
parent
d372f051
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
22 deletions
+70
-22
dynamic_imports.rs
crates/next-api/src/dynamic_imports.rs
+61
-18
pattern_mapping.rs
...es/turbopack-ecmascript/src/references/pattern_mapping.rs
+9
-4
No files found.
crates/next-api/src/dynamic_imports.rs
View file @
08dc46f3
...
@@ -19,15 +19,16 @@
...
@@ -19,15 +19,16 @@
//! to wait until all the dynamic components are being loaded, this ensures hydration mismatch
//! to wait until all the dynamic components are being loaded, this ensures hydration mismatch
//! won't occur
//! won't occur
use
anyhow
::{
Context
,
Result
};
use
anyhow
::{
Result
,
bail
};
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
next_core
::{
use
next_core
::{
next_app
::
ClientReferencesChunks
,
next_client_reference
::
EcmascriptClientReferenceModule
,
next_app
::
ClientReferencesChunks
,
next_client_reference
::{
ClientReferenceType
,
EcmascriptClientReferenceModule
},
next_dynamic
::
NextDynamicEntryModule
,
next_dynamic
::
NextDynamicEntryModule
,
};
};
use
turbo_tasks
::{
use
turbo_tasks
::{
FxIndexMap
,
NonLocalValue
,
ReadRef
,
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Vc
,
FxIndexMap
,
NonLocalValue
,
ReadRef
,
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
ValueToString
,
Vc
,
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
};
};
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
ChunkGroupResult
,
ChunkableModule
},
chunk
::{
ChunkGroupResult
,
ChunkableModule
},
...
@@ -38,6 +39,19 @@ use turbopack_core::{
...
@@ -38,6 +39,19 @@ use turbopack_core::{
use
crate
::
module_graph
::
DynamicImportEntriesWithImporter
;
use
crate
::
module_graph
::
DynamicImportEntriesWithImporter
;
/// Helper to get a descriptive string for a ClientReferenceType
async
fn
client_reference_type_to_string
(
ty
:
&
ClientReferenceType
)
->
Result
<
String
>
{
match
ty
{
ClientReferenceType
::
EcmascriptClientReference
(
ecma_ref
)
=>
{
let
module
=
ecma_ref
.await
?
;
Ok
(
module
.server_ident
.to_string
()
.await
?
.to_string
())
}
ClientReferenceType
::
CssClientReference
(
css_ref
)
=>
{
Ok
(
css_ref
.ident
()
.to_string
()
.await
?
.to_string
())
}
}
}
pub
(
crate
)
enum
NextDynamicChunkAvailability
<
'a
>
{
pub
(
crate
)
enum
NextDynamicChunkAvailability
<
'a
>
{
/// In App Router, the client references chunks contain the async loaders
/// In App Router, the client references chunks contain the async loaders
ClientReferences
(
&
'a
ClientReferencesChunks
),
ClientReferences
(
&
'a
ClientReferencesChunks
),
...
@@ -67,26 +81,55 @@ pub(crate) async fn collect_next_dynamic_chunks(
...
@@ -67,26 +81,55 @@ pub(crate) async fn collect_next_dynamic_chunks(
NextDynamicChunkAvailability
::
ClientReferences
(
client_reference_chunks
)
=>
{
NextDynamicChunkAvailability
::
ClientReferences
(
client_reference_chunks
)
=>
{
// For App Router: look up the chunk group for the parent client reference,
// For App Router: look up the chunk group for the parent client reference,
// then find the async loader for this dynamic entry
// then find the async loader for this dynamic entry
let
parent_ref
=
parent_client_reference
let
Some
(
parent_ref
)
=
parent_client_reference
else
{
.context
(
"Parent client reference not found for next/dynamic import"
)
?
;
let
dynamic_ident
=
dynamic_entry
.ident
()
.to_string
()
.await
?
;
let
chunk_group
=
client_reference_chunks
bail!
(
"Parent client reference not found for next/dynamic import.
\n
Dynamic
\
entry: {dynamic_ident}"
);
};
let
Some
(
chunk_group_vc
)
=
client_reference_chunks
.client_component_client_chunks
.client_component_client_chunks
.get
(
&
parent_ref
)
.get
(
parent_ref
)
.context
(
"Client reference chunk group not found for next/dynamic import"
)
?
else
{
.await
?
;
let
dynamic_ident
=
dynamic_entry
.ident
()
.to_string
()
.await
?
;
let
parent_ident
=
client_reference_type_to_string
(
parent_ref
)
.await
?
;
bail!
(
"Client reference chunk group not found for next/dynamic
\
import.
\n
Dynamic entry: {dynamic_ident}
\n
Parent client reference:
\
{parent_ident}"
);
};
let
chunk_group
=
chunk_group_vc
.await
?
;
// Copy the ResolvedVc out of the map to avoid lifetime issues
// Copy the ResolvedVc out of the map to avoid lifetime issues
*
chunk_group
.async_loaders_by_module
.get
(
&
module
)
.context
(
let
Some
(
loader
)
=
chunk_group
.async_loaders_by_module
.get
(
&
module
)
else
{
"Dynamic entry not found in async loaders - this may indicate the dynamic
\
let
dynamic_ident
=
dynamic_entry
.ident
()
.to_string
()
.await
?
;
import is not reachable from the client reference"
,
let
parent_ident
=
client_reference_type_to_string
(
parent_ref
)
.await
?
;
)
?
let
available_count
=
chunk_group
.async_loaders_by_module
.len
();
bail!
(
"Dynamic entry not found in async loaders - this may indicate the
\
dynamic import is not reachable from the client reference.
\n
Dynamic
\
entry: {dynamic_ident}
\n
Parent client reference:
\
{parent_ident}
\n
Available async loaders in chunk group:
\
{available_count}"
);
};
*
loader
}
}
NextDynamicChunkAvailability
::
PageChunkGroup
(
chunk_group
)
=>
{
NextDynamicChunkAvailability
::
PageChunkGroup
(
chunk_group
)
=>
{
// For Pages Router: look up directly in the page's chunk group
// For Pages Router: look up directly in the page's chunk group
// Copy the ResolvedVc out of the map to avoid lifetime issues
// Copy the ResolvedVc out of the map to avoid lifetime issues
*
chunk_group
.async_loaders_by_module
.get
(
&
module
)
.context
(
let
Some
(
loader
)
=
chunk_group
.async_loaders_by_module
.get
(
&
module
)
else
{
"Dynamic entry not found in async loaders - this may indicate the dynamic
\
let
dynamic_ident
=
dynamic_entry
.ident
()
.to_string
()
.await
?
;
import is not reachable from the page entry"
,
let
available_count
=
chunk_group
.async_loaders_by_module
.len
();
)
?
bail!
(
"Dynamic entry not found in async loaders - this may indicate the
\
dynamic import is not reachable from the page entry.
\n
Dynamic entry:
\
{dynamic_ident}
\n
Available async loaders in chunk group:
\
{available_count}"
);
};
*
loader
}
}
};
};
...
...
turbopack/crates/turbopack-ecmascript/src/references/pattern_mapping.rs
View file @
08dc46f3
...
@@ -12,7 +12,8 @@ use swc_core::{
...
@@ -12,7 +12,8 @@ use swc_core::{
};
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
use
turbo_tasks
::{
FxIndexMap
,
NonLocalValue
,
ResolvedVc
,
TaskInput
,
TryJoinIterExt
,
Vc
,
debug
::
ValueDebugFormat
,
FxIndexMap
,
NonLocalValue
,
ResolvedVc
,
TaskInput
,
TryJoinIterExt
,
Vc
,
debug
::{
ValueDebug
,
ValueDebugFormat
},
trace
::
TraceRawVcs
,
trace
::
TraceRawVcs
,
};
};
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -372,9 +373,13 @@ async fn to_single_pattern_mapping(
...
@@ -372,9 +373,13 @@ async fn to_single_pattern_mapping(
CodeGenerationIssue
{
CodeGenerationIssue
{
severity
:
IssueSeverity
::
Bug
,
severity
:
IssueSeverity
::
Bug
,
title
:
StyledString
::
Text
(
rcstr!
(
"non-ecmascript placeable asset"
))
.resolved_cell
(),
title
:
StyledString
::
Text
(
rcstr!
(
"non-ecmascript placeable asset"
))
.resolved_cell
(),
message
:
StyledString
::
Text
(
rcstr!
(
message
:
StyledString
::
Text
(
"asset is not placeable in ESM chunks, so it doesn't have a module id"
format!
(
))
"asset is not placeable in ESM chunks, so it doesn't have a module id: {}"
,
module
.dbg_depth
(
2
)
.await
?
)
.into
(),
)
.resolved_cell
(),
.resolved_cell
(),
path
:
origin
.origin_path
()
.owned
()
.await
?
,
path
:
origin
.origin_path
()
.owned
()
.await
?
,
source
:
None
,
source
:
None
,
...
...
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