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
ef993b25
Unverified
Commit
ef993b25
authored
Feb 27, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 27, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `VisitMut` instead of `Fold` for debug_instant_stack transform (#90274)
parent
bb813afd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
debug_instant_stack.rs
...t-custom-transforms/src/transforms/debug_instant_stack.rs
+8
-13
No files found.
crates/next-custom-transforms/src/transforms/debug_instant_stack.rs
View file @
ef993b25
...
...
@@ -4,7 +4,7 @@ use swc_core::{
common
::{
Span
,
Spanned
},
ecma
::{
ast
::
*
,
visit
::{
Fold
,
fold
_pass
},
visit
::{
VisitMut
,
visit_mut
_pass
},
},
quote
,
};
...
...
@@ -14,7 +14,7 @@ static PAGE_OR_LAYOUT_RE: Lazy<Regex> =
Lazy
::
new
(||
Regex
::
new
(
r
"[
\\
/](page|layout|default)
\
.(ts|js)x?$"
)
.unwrap
());
pub
fn
debug_instant_stack
(
filepath
:
String
)
->
impl
Pass
{
fold
_pass
(
DebugInstantStack
{
visit_mut
_pass
(
DebugInstantStack
{
filepath
,
instant_export_span
:
None
,
})
...
...
@@ -71,13 +71,13 @@ fn find_var_init_span(items: &[ModuleItem], local_name: &str) -> Option<Span> {
None
}
impl
Fold
for
DebugInstantStack
{
fn
fold_module_items
(
&
mut
self
,
items
:
Vec
<
ModuleItem
>
)
->
Vec
<
ModuleItem
>
{
impl
VisitMut
for
DebugInstantStack
{
fn
visit_mut_module_items
(
&
mut
self
,
items
:
&
mut
Vec
<
ModuleItem
>
)
{
if
!
PAGE_OR_LAYOUT_RE
.is_match
(
&
self
.filepath
)
{
return
items
;
return
;
}
for
item
in
&
items
{
for
item
in
items
.iter
()
{
match
item
{
// `export const unstable_instant = ...`
ModuleItem
::
ModuleDecl
(
ModuleDecl
::
ExportDecl
(
export_decl
))
=>
{
...
...
@@ -104,7 +104,7 @@ impl Fold for DebugInstantStack {
}
else
{
// Local named export: try to find the variable's initializer
let
local_name
=
&
orig
.sym
;
if
let
Some
(
init_span
)
=
find_var_init_span
(
&
items
,
local_name
)
{
if
let
Some
(
init_span
)
=
find_var_init_span
(
items
,
local_name
)
{
self
.instant_export_span
=
Some
(
init_span
);
}
else
{
// Fallback to the export specifier span
...
...
@@ -119,8 +119,6 @@ impl Fold for DebugInstantStack {
}
if
let
Some
(
source_span
)
=
self
.instant_export_span
{
let
mut
new_items
=
items
;
// TODO: Change React to deserialize errors with a zero-length message
// instead of using a fallback message ("no message was provided").
// We're working around this by using a message that is empty
...
...
@@ -152,10 +150,7 @@ impl Fold for DebugInstantStack {
cons
:
Expr
=
cons
,
);
new_items
.push
(
export
);
new_items
}
else
{
items
items
.push
(
export
);
}
}
}
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