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
e5c53365
Unverified
Commit
e5c53365
authored
Oct 31, 2024
by
Hendrik Liebau
Committed by
GitHub
Oct 31, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix source mapping dev middlewares for Windows (#72139)
parent
3650f478
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
10 deletions
+31
-10
get-source-map-from-file.ts
...-dev-overlay/internal/helpers/get-source-map-from-file.ts
+4
-1
middleware-turbopack.ts
...mponents/react-dev-overlay/server/middleware-turbopack.ts
+21
-7
middleware.ts
.../client/components/react-dev-overlay/server/middleware.ts
+6
-1
webpack.config.js
packages/next/webpack.config.js
+0
-1
No files found.
packages/next/src/client/components/react-dev-overlay/internal/helpers/get-source-map-from-file.ts
View file @
e5c53365
...
@@ -54,7 +54,10 @@ export async function getSourceMapFromFile(
...
@@ -54,7 +54,10 @@ export async function getSourceMapFromFile(
}
}
}
}
const
sourceMapFilename
=
path
.
resolve
(
path
.
dirname
(
filename
),
sourceUrl
)
const
sourceMapFilename
=
path
.
resolve
(
path
.
dirname
(
filename
),
decodeURIComponent
(
sourceUrl
)
)
try
{
try
{
const
sourceMapContents
=
await
fs
.
readFile
(
sourceMapFilename
,
'utf-8'
)
const
sourceMapContents
=
await
fs
.
readFile
(
sourceMapFilename
,
'utf-8'
)
...
...
packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts
View file @
e5c53365
...
@@ -12,10 +12,12 @@ import {
...
@@ -12,10 +12,12 @@ import {
import
fs
,
{
constants
as
FS
}
from
'fs/promises'
import
fs
,
{
constants
as
FS
}
from
'fs/promises'
import
path
from
'path'
import
path
from
'path'
import
url
from
'url'
import
{
launchEditor
}
from
'../internal/helpers/launchEditor'
import
{
launchEditor
}
from
'../internal/helpers/launchEditor'
import
type
{
StackFrame
}
from
'next/dist/compiled/stacktrace-parser'
import
type
{
StackFrame
}
from
'next/dist/compiled/stacktrace-parser'
import
type
{
Project
,
TurbopackStackFrame
}
from
'../../../../build/swc/types'
import
type
{
Project
,
TurbopackStackFrame
}
from
'../../../../build/swc/types'
import
{
getSourceMapFromFile
}
from
'../internal/helpers/get-source-map-from-file'
import
{
getSourceMapFromFile
}
from
'../internal/helpers/get-source-map-from-file'
import
{
findSourceMap
}
from
'node:module'
const
currentSourcesByFile
:
Map
<
string
,
Promise
<
string
|
null
>>
=
new
Map
()
const
currentSourcesByFile
:
Map
<
string
,
Promise
<
string
|
null
>>
=
new
Map
()
export
async
function
batchedTraceSource
(
export
async
function
batchedTraceSource
(
...
@@ -169,17 +171,29 @@ export function getSourceMapMiddleware(project: Project, distDir: string) {
...
@@ -169,17 +171,29 @@ export function getSourceMapMiddleware(project: Project, distDir: string) {
return
badRequest
(
res
)
return
badRequest
(
res
)
}
}
if
(
filename
.
startsWith
(
'webpack://next/'
))
{
if
(
filename
.
startsWith
(
'webpack://'
)
||
filename
.
startsWith
(
'webpack-internal:///'
)
)
{
const
sourceMap
=
findSourceMap
(
filename
)
if
(
sourceMap
)
{
return
json
(
res
,
sourceMap
.
payload
)
}
return
noContent
(
res
)
return
noContent
(
res
)
}
}
try
{
try
{
if
(
filename
.
startsWith
(
'/_next/static'
))
{
if
(
filename
.
startsWith
(
'/_next/static'
))
{
filename
=
path
.
join
(
filename
=
path
.
join
(
distDir
,
filename
.
replace
(
/^
\/
_next
\/
/
,
''
))
distDir
,
}
// /_next/static/chunks/%5Bproject%5D... => static/chunks/[project]...
decodeURIComponent
(
filename
.
replace
(
/^
\/
_next
\/
/
,
''
))
// Turbopack chunk filenames might be URL-encoded.
)
filename
=
decodeURI
(
filename
)
if
(
path
.
isAbsolute
(
filename
))
{
filename
=
url
.
pathToFileURL
(
filename
).
href
}
}
const
sourceMapString
=
await
project
.
getSourceMap
(
filename
)
const
sourceMapString
=
await
project
.
getSourceMap
(
filename
)
...
@@ -188,7 +202,7 @@ export function getSourceMapMiddleware(project: Project, distDir: string) {
...
@@ -188,7 +202,7 @@ export function getSourceMapMiddleware(project: Project, distDir: string) {
return
jsonString
(
res
,
sourceMapString
)
return
jsonString
(
res
,
sourceMapString
)
}
}
if
(
filename
.
startsWith
(
'file:'
)
||
filename
.
startsWith
(
path
.
sep
)
)
{
if
(
filename
.
startsWith
(
'file:'
))
{
const
sourceMap
=
await
getSourceMapFromFile
(
filename
)
const
sourceMap
=
await
getSourceMapFromFile
(
filename
)
if
(
sourceMap
)
{
if
(
sourceMap
)
{
...
...
packages/next/src/client/components/react-dev-overlay/server/middleware.ts
View file @
e5c53365
import
{
constants
as
FS
,
promises
as
fs
}
from
'fs'
import
{
constants
as
FS
,
promises
as
fs
}
from
'fs'
import
path
from
'path'
import
path
from
'path'
import
url
from
'url'
import
{
SourceMapConsumer
}
from
'next/dist/compiled/source-map08'
import
{
SourceMapConsumer
}
from
'next/dist/compiled/source-map08'
import
type
{
StackFrame
}
from
'next/dist/compiled/stacktrace-parser'
import
type
{
StackFrame
}
from
'next/dist/compiled/stacktrace-parser'
import
{
getSourceMapFromFile
}
from
'../internal/helpers/get-source-map-from-file'
import
{
getSourceMapFromFile
}
from
'../internal/helpers/get-source-map-from-file'
...
@@ -213,7 +214,11 @@ export async function getSource(
...
@@ -213,7 +214,11 @@ export async function getSource(
filename
=
path
.
join
(
distDirectory
,
filename
.
replace
(
/^
\/
_next
\/
/
,
''
))
filename
=
path
.
join
(
distDirectory
,
filename
.
replace
(
/^
\/
_next
\/
/
,
''
))
}
}
if
(
filename
.
startsWith
(
'file:'
)
||
filename
.
startsWith
(
path
.
sep
))
{
if
(
path
.
isAbsolute
(
filename
))
{
filename
=
url
.
pathToFileURL
(
filename
).
href
}
if
(
filename
.
startsWith
(
'file:'
))
{
const
sourceMap
=
await
getSourceMapFromFile
(
filename
)
const
sourceMap
=
await
getSourceMapFromFile
(
filename
)
return
sourceMap
return
sourceMap
...
...
packages/next/webpack.config.js
View file @
e5c53365
...
@@ -154,7 +154,6 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => {
...
@@ -154,7 +154,6 @@ module.exports = ({ dev, turbo, bundleType, experimental }) => {
experimental
?
'-experimental'
:
''
experimental
?
'-experimental'
:
''
}
.runtime.
${
dev
?
'dev'
:
'prod'
}
.js`
,
}
.runtime.
${
dev
?
'dev'
:
'prod'
}
.js`
,
libraryTarget
:
'commonjs2'
,
libraryTarget
:
'commonjs2'
,
devtoolModuleFilenameTemplate
:
'./[resource-path]'
,
},
},
devtool
:
process
.
env
.
NEXT_SERVER_EVAL_SOURCE_MAPS
devtool
:
process
.
env
.
NEXT_SERVER_EVAL_SOURCE_MAPS
?
'eval-source-map'
?
'eval-source-map'
...
...
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