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
3bd2711c
Unverified
Commit
3bd2711c
authored
May 15, 2020
by
Joe Haddad
Committed by
GitHub
May 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fast Refresh] Improve responsiveness on Windows (#12909)
parent
c2127899
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
42 deletions
+96
-42
base.ts
packages/next/build/webpack/config/blocks/base.ts
+22
-18
client.ts
packages/react-dev-overlay/src/client.ts
+1
-1
getRawSourceMap.ts
...react-dev-overlay/src/internal/helpers/getRawSourceMap.ts
+1
-1
parseStack.ts
...ages/react-dev-overlay/src/internal/helpers/parseStack.ts
+22
-0
ReactRefreshLogBox.test.js
test/acceptance/ReactRefreshLogBox.test.js
+50
-22
No files found.
packages/next/build/webpack/config/blocks/base.ts
View file @
3bd2711c
...
@@ -11,24 +11,28 @@ export const base = curry(function base(
...
@@ -11,24 +11,28 @@ export const base = curry(function base(
config
.
target
=
ctx
.
isServer
?
'node'
:
'web'
config
.
target
=
ctx
.
isServer
?
'node'
:
'web'
// https://webpack.js.org/configuration/devtool/#development
// https://webpack.js.org/configuration/devtool/#development
config
.
devtool
=
ctx
.
isDevelopment
if
(
ctx
.
isDevelopment
)
{
?
ctx
.
isReactRefreshEnabled
if
(
ctx
.
isReactRefreshEnabled
)
{
?
ctx
.
isServer
if
(
ctx
.
isServer
||
process
.
platform
===
'win32'
)
{
?
// Non-eval based source maps are very slow to rebuild, so we only
// Non-eval based source maps are slow to rebuild, so we only enable
// enable them for the server. Unfortunately, eval source maps are
// them for the server and Windows. Unfortunately, eval source maps
// not supported by Node.js.
// are not supported by Node.js, and are slow on Windows.
'inline-source-map'
config
.
devtool
=
'inline-source-map'
:
// `eval-source-map` provides full-fidelity source maps for the
}
else
{
// original source, including columns and original variable names.
// `eval-source-map` provides full-fidelity source maps for the
// This is desirable so the in-browser debugger can correctly pause
// original source, including columns and original variable names.
// and show scoped variables with their original names.
// This is desirable so the in-browser debugger can correctly pause
'eval-source-map'
// and show scoped variables with their original names.
:
// `cheap-module-source-map` is the old preferred format that was
config
.
devtool
=
'eval-source-map'
// required for `react-error-overlay`.
}
'cheap-module-source-map'
}
else
{
:
ctx
.
isProduction
// `cheap-module-source-map` is the old preferred format that was
?
false
// required for `react-error-overlay`.
:
false
config
.
devtool
=
'cheap-module-source-map'
}
}
else
{
config
.
devtool
=
false
}
if
(
!
config
.
module
)
{
if
(
!
config
.
module
)
{
config
.
module
=
{
rules
:
[]
}
config
.
module
=
{
rules
:
[]
}
...
...
packages/react-dev-overlay/src/client.ts
View file @
3bd2711c
import
{
parse
as
parseStack
}
from
'stacktrace-parser'
import
*
as
Bus
from
'./internal/bus'
import
*
as
Bus
from
'./internal/bus'
import
{
parseStack
}
from
'./internal/helpers/parseStack'
let
isRegistered
=
false
let
isRegistered
=
false
let
stackTraceLimit
:
number
|
undefined
=
undefined
let
stackTraceLimit
:
number
|
undefined
=
undefined
...
...
packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts
View file @
3bd2711c
...
@@ -4,7 +4,7 @@ import { getSourceMapUrl } from './getSourceMapUrl'
...
@@ -4,7 +4,7 @@ import { getSourceMapUrl } from './getSourceMapUrl'
export
function
getRawSourceMap
(
fileContents
:
string
):
RawSourceMap
|
null
{
export
function
getRawSourceMap
(
fileContents
:
string
):
RawSourceMap
|
null
{
const
sourceUrl
=
getSourceMapUrl
(
fileContents
)
const
sourceUrl
=
getSourceMapUrl
(
fileContents
)
if
(
sourceUrl
==
null
)
{
if
(
!
sourceUrl
?.
startsWith
(
'data:'
)
)
{
return
null
return
null
}
}
...
...
packages/react-dev-overlay/src/internal/helpers/parseStack.ts
0 → 100644
View file @
3bd2711c
import
{
parse
,
StackFrame
}
from
'stacktrace-parser'
const
regexNextStatic
=
/
\/
_next
(\/
static
\/
.+
)
/g
export
function
parseStack
(
stack
:
string
):
StackFrame
[]
{
const
frames
=
parse
(
stack
)
return
frames
.
map
(
frame
=>
{
try
{
const
url
=
new
URL
(
frame
.
file
)
const
res
=
regexNextStatic
.
exec
(
url
.
pathname
)
if
(
res
)
{
const
distDir
=
process
.
env
.
__NEXT_DIST_DIR
?.
replace
(
/
\\
/g
,
'/'
)
?.
replace
(
/
\/
$/
,
''
)
if
(
distDir
)
{
frame
.
file
=
'file://'
+
distDir
.
concat
(
res
.
pop
())
}
}
}
catch
{}
return
frame
})
}
test/acceptance/ReactRefreshLogBox.test.js
View file @
3bd2711c
...
@@ -101,17 +101,31 @@ test('logbox: can recover from a event handler error', async () => {
...
@@ -101,17 +101,31 @@ test('logbox: can recover from a event handler error', async () => {
).
toBe
(
'1'
)
).
toBe
(
'1'
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
if
(
process
.
platform
===
'win32'
)
{
"index.js (8:16) @ eval
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (8:16) @ <unknown>
6 | const increment = useCallback(() => {
7 | setCount(c => c + 1)
6 | const increment = useCallback(() => {
> 8 | throw new Error('oops')
7 | setCount(c => c + 1)
| ^
> 8 | throw new Error('oops')
9 | }, [setCount])
| ^
10 | return (
9 | }, [setCount])
11 | <main>"
10 | return (
`
)
11 | <main>"
`
)
}
else
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (8:16) @ eval
6 | const increment = useCallback(() => {
7 | setCount(c => c + 1)
> 8 | throw new Error('oops')
| ^
9 | }, [setCount])
10 | return (
11 | <main>"
`
)
}
await
session
.
patch
(
await
session
.
patch
(
'index.js'
,
'index.js'
,
...
@@ -466,17 +480,31 @@ test('syntax > runtime error', async () => {
...
@@ -466,17 +480,31 @@ test('syntax > runtime error', async () => {
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
if
(
process
.
platform
===
'win32'
)
{
"index.js (6:14) @ eval
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (6:14) @ <unknown>
4 | setInterval(() => {
5 | i++
4 | setInterval(() => {
> 6 | throw Error('no ' + i)
5 | i++
| ^
> 6 | throw Error('no ' + i)
7 | }, 1000)
| ^
8 | export default function FunctionNamed() {
7 | }, 1000)
9 | return <div />"
8 | export default function FunctionNamed() {
`
)
9 | return <div />"
`
)
}
else
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (6:14) @ eval
4 | setInterval(() => {
5 | i++
> 6 | throw Error('no ' + i)
| ^
7 | }, 1000)
8 | export default function FunctionNamed() {
9 | return <div />"
`
)
}
// Make a syntax error.
// Make a syntax error.
await
session
.
patch
(
await
session
.
patch
(
...
...
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