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
4498be3b
Commit
4498be3b
authored
Oct 21, 2025
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restrict free call optimization to turbopack identifiers for now
parent
efec7ab9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
magic-identifier.test.ts
packages/next/src/shared/lib/magic-identifier.test.ts
+10
-10
magic-identifier.ts
packages/next/src/shared/lib/magic-identifier.ts
+1
-1
No files found.
packages/next/src/shared/lib/magic-identifier.test.ts
View file @
4498be3b
...
...
@@ -78,11 +78,15 @@ describe('deobfuscateModuleId', () => {
describe
(
'removeFreeCallWrapper'
,
()
=>
{
test
(
'removes (0, ) wrapper'
,
()
=>
{
expect
(
removeFreeCallWrapper
(
'(0, foo.bar)'
)).
toBe
(
'foo.bar'
)
expect
(
removeFreeCallWrapper
(
'(0, __TURBOPACK__foo__.bar)'
)).
toBe
(
'__TURBOPACK__foo__.bar'
)
})
test
(
'removes (0 , ) wrapper with spaces'
,
()
=>
{
expect
(
removeFreeCallWrapper
(
'(0 , foo.bar)'
)).
toBe
(
'foo.bar'
)
expect
(
removeFreeCallWrapper
(
'(0 , __TURBOPACK__foo__.bar)'
)).
toBe
(
'__TURBOPACK__foo__.bar'
)
})
test
(
'leaves non-free-call expressions unchanged'
,
()
=>
{
...
...
@@ -96,20 +100,16 @@ describe('deobfuscateText', () => {
const
input
=
'(0 , __TURBOPACK__imported__module__$5b$project$5d2f$examples$2f$with$2d$turbopack$2f$app$2f$foo$2e$ts__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__.foo) is not a function'
const
output
=
deobfuscateText
(
input
)
expect
(
output
).
toContain
(
'imported module'
)
expect
(
output
).
toContain
(
'./examples/with-turbopack/app/foo.ts'
)
expect
(
output
).
not
.
toContain
(
'[project]'
)
expect
(
output
).
not
.
toContain
(
'[app-rsc]'
)
expect
(
output
).
not
.
toContain
(
'(ecmascript)'
)
expect
(
output
).
not
.
toContain
(
'(0 ,'
)
expect
(
output
).
toBe
(
'{imported module ./examples/with-turbopack/app/foo.ts}.foo is not a function'
)
})
test
(
'handles multiple magic identifiers'
,
()
=>
{
const
input
=
'__TURBOPACK__module__evaluation__ called __TURBOPACK__foo$2f$bar__'
const
output
=
deobfuscateText
(
input
)
expect
(
output
).
toContain
(
'module evaluation'
)
expect
(
output
).
toContain
(
'foo/bar'
)
expect
(
output
).
toBe
(
'{module evaluation} called {foo/bar}'
)
})
test
(
'leaves regular text unchanged'
,
()
=>
{
...
...
packages/next/src/shared/lib/magic-identifier.ts
View file @
4498be3b
...
...
@@ -125,7 +125,7 @@ export function removeFreeCallWrapper(text: string): string {
// Use Unicode property escapes (\p{ID_Start}, \p{ID_Continue}) for full JS identifier support
// Requires the 'u' (unicode) flag in the regex
return
text
.
replace
(
/
\(
0
\s
*,
\s
*
(
[\p
{ID_Start}_$
][\p
{ID_Continue}$
]
*
\.[\p
{ID_Start}_$
][\p
{ID_Continue}$
]
*
)\)
/
u
,
/
\(
0
\s
*,
\s
*
(
__TURBOPACK__
[
a-zA-Z0-9_$
]
+__
\.[\p
{ID_Start}_$
][\p
{ID_Continue}$
]
*
)\)
/
u
,
'$1'
)
}
...
...
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