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
79494d2c
Commit
79494d2c
authored
Feb 26, 2026
by
Will Binns-Smith
Committed by
Will Binns-Smith
Feb 26, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
4d4dbf2e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
page.tsx
test/development/app-dir/server-hmr/app/sourcemaps/page.tsx
+5
-0
server-hmr.test.ts
test/development/app-dir/server-hmr/server-hmr.test.ts
+27
-0
hmr-client.ts
...bopack-ecmascript-runtime/js/src/nodejs/dev/hmr-client.ts
+2
-2
No files found.
test/development/app-dir/server-hmr/app/sourcemaps/page.tsx
0 → 100644
View file @
79494d2c
// hmr-trigger: 0
export
default
function
Page
()
{
throw
new
Error
(
'hmr-sourcemap-test-error'
)
}
test/development/app-dir/server-hmr/server-hmr.test.ts
View file @
79494d2c
...
@@ -127,4 +127,31 @@ describe('server-hmr', () => {
...
@@ -127,4 +127,31 @@ describe('server-hmr', () => {
}
}
)
)
})
})
describe
(
'source maps'
,
()
=>
{
itTurbopackDev
(
"stack frames from eval'd HMR modules point to original source locations"
,
async
()
=>
{
await
next
.
fetch
(
'/sourcemaps'
).
catch
(()
=>
{})
await
next
.
patchFile
(
'app/sourcemaps/page.tsx'
,
(
content
)
=>
content
.
replace
(
'hmr-trigger: 0'
,
'hmr-trigger: 1'
)
)
const
outputLengthBeforeFetch
=
next
.
cliOutput
.
length
await
next
.
fetch
(
'/sourcemaps'
).
catch
(()
=>
{})
await
retry
(
async
()
=>
{
expect
(
next
.
cliOutput
.
slice
(
outputLengthBeforeFetch
)).
toContain
(
'hmr-sourcemap-test-error'
)
})
const
outputAfterHmr
=
next
.
cliOutput
.
slice
(
outputLengthBeforeFetch
)
// Without proper sourcemaps, the stack frame doesn't include the accurate file number
expect
(
outputAfterHmr
).
toMatch
(
/page
\.
tsx:6:/
)
}
)
})
})
})
turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/dev/hmr-client.ts
View file @
79494d2c
...
@@ -18,7 +18,7 @@ type NodeJsHmrPayload = {
...
@@ -18,7 +18,7 @@ type NodeJsHmrPayload = {
* that Node.js can resolve stack frames from `eval`ed server HMR modules back to
* that Node.js can resolve stack frames from `eval`ed server HMR modules back to
* their original source files. Mirrors the browser's _eval in dev-backend-dom.ts.
* their original source files. Mirrors the browser's _eval in dev-backend-dom.ts.
*/
*/
function
maybeI
nlineSourcemaps
(
entry
:
EcmascriptModuleEntry
):
string
{
function
i
nlineSourcemaps
(
entry
:
EcmascriptModuleEntry
):
string
{
const
[
chunkPath
,
moduleId
]
=
entry
.
url
.
split
(
'?'
,
2
)
const
[
chunkPath
,
moduleId
]
=
entry
.
url
.
split
(
'?'
,
2
)
const
absolutePath
=
path
.
resolve
(
RUNTIME_ROOT
,
chunkPath
)
const
absolutePath
=
path
.
resolve
(
RUNTIME_ROOT
,
chunkPath
)
const
fileHref
=
url
.
pathToFileURL
(
absolutePath
).
href
const
fileHref
=
url
.
pathToFileURL
(
absolutePath
).
href
...
@@ -96,7 +96,7 @@ function handleNodejsUpdate(
...
@@ -96,7 +96,7 @@ function handleNodejsUpdate(
const
evalModuleEntry
=
(
entry
:
EcmascriptModuleEntry
)
=>
{
const
evalModuleEntry
=
(
entry
:
EcmascriptModuleEntry
)
=>
{
// eslint-disable-next-line no-eval
// eslint-disable-next-line no-eval
return
(
0
,
eval
)(
maybeInlineSourcemaps
(
entry
)
)
return
(
0
,
eval
)(
entry
.
map
?
inlineSourcemaps
(
entry
)
:
entry
.
code
)
}
}
const
{
added
,
modified
}
=
computeChangedModules
(
const
{
added
,
modified
}
=
computeChangedModules
(
...
...
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