Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
3bd2711c
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3bd2711c
编写于
5月 15, 2020
作者:
J
Joe Haddad
提交者:
GitHub
5月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Fast Refresh] Improve responsiveness on Windows (#12909)
上级
c2127899
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
96 addition
and
42 deletion
+96
-42
packages/next/build/webpack/config/blocks/base.ts
packages/next/build/webpack/config/blocks/base.ts
+22
-18
packages/react-dev-overlay/src/client.ts
packages/react-dev-overlay/src/client.ts
+1
-1
packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts
...react-dev-overlay/src/internal/helpers/getRawSourceMap.ts
+1
-1
packages/react-dev-overlay/src/internal/helpers/parseStack.ts
...ages/react-dev-overlay/src/internal/helpers/parseStack.ts
+22
-0
test/acceptance/ReactRefreshLogBox.test.js
test/acceptance/ReactRefreshLogBox.test.js
+50
-22
未找到文件。
packages/next/build/webpack/config/blocks/base.ts
浏览文件 @
3bd2711c
...
...
@@ -11,24 +11,28 @@ export const base = curry(function base(
config
.
target
=
ctx
.
isServer
?
'
node
'
:
'
web
'
// https://webpack.js.org/configuration/devtool/#development
config
.
devtool
=
ctx
.
isDevelopment
?
ctx
.
isReactRefreshEnabled
?
ctx
.
isServer
?
// Non-eval based source maps are very slow to rebuild, so we only
// enable them for the server. Unfortunately, eval source maps are
// not supported by Node.js.
'
inline-source-map
'
:
// `eval-source-map` provides full-fidelity source maps for the
// original source, including columns and original variable names.
// This is desirable so the in-browser debugger can correctly pause
// and show scoped variables with their original names.
'
eval-source-map
'
:
// `cheap-module-source-map` is the old preferred format that was
// required for `react-error-overlay`.
'
cheap-module-source-map
'
:
ctx
.
isProduction
?
false
:
false
if
(
ctx
.
isDevelopment
)
{
if
(
ctx
.
isReactRefreshEnabled
)
{
if
(
ctx
.
isServer
||
process
.
platform
===
'
win32
'
)
{
// Non-eval based source maps are slow to rebuild, so we only enable
// them for the server and Windows. Unfortunately, eval source maps
// are not supported by Node.js, and are slow on Windows.
config
.
devtool
=
'
inline-source-map
'
}
else
{
// `eval-source-map` provides full-fidelity source maps for the
// original source, including columns and original variable names.
// This is desirable so the in-browser debugger can correctly pause
// and show scoped variables with their original names.
config
.
devtool
=
'
eval-source-map
'
}
}
else
{
// `cheap-module-source-map` is the old preferred format that was
// required for `react-error-overlay`.
config
.
devtool
=
'
cheap-module-source-map
'
}
}
else
{
config
.
devtool
=
false
}
if
(
!
config
.
module
)
{
config
.
module
=
{
rules
:
[]
}
...
...
packages/react-dev-overlay/src/client.ts
浏览文件 @
3bd2711c
import
{
parse
as
parseStack
}
from
'
stacktrace-parser
'
import
*
as
Bus
from
'
./internal/bus
'
import
{
parseStack
}
from
'
./internal/helpers/parseStack
'
let
isRegistered
=
false
let
stackTraceLimit
:
number
|
undefined
=
undefined
...
...
packages/react-dev-overlay/src/internal/helpers/getRawSourceMap.ts
浏览文件 @
3bd2711c
...
...
@@ -4,7 +4,7 @@ import { getSourceMapUrl } from './getSourceMapUrl'
export
function
getRawSourceMap
(
fileContents
:
string
):
RawSourceMap
|
null
{
const
sourceUrl
=
getSourceMapUrl
(
fileContents
)
if
(
sourceUrl
==
null
)
{
if
(
!
sourceUrl
?.
startsWith
(
'
data:
'
)
)
{
return
null
}
...
...
packages/react-dev-overlay/src/internal/helpers/parseStack.ts
0 → 100644
浏览文件 @
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
浏览文件 @
3bd2711c
...
...
@@ -101,17 +101,31 @@ test('logbox: can recover from a event handler error', async () => {
).
toBe
(
'
1
'
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
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>"
`
)
if
(
process
.
platform
===
'
win32
'
)
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (8:16) @ <unknown>
6 | const increment = useCallback(() => {
7 | setCount(c => c + 1)
> 8 | throw new Error('oops')
| ^
9 | }, [setCount])
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
(
'
index.js
'
,
...
...
@@ -466,17 +480,31 @@ test('syntax > runtime error', async () => {
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
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 />"
`
)
if
(
process
.
platform
===
'
win32
'
)
{
expect
(
await
session
.
getRedboxSource
()).
toMatchInlineSnapshot
(
`
"index.js (6:14) @ <unknown>
4 | setInterval(() => {
5 | i++
> 6 | throw Error('no ' + i)
| ^
7 | }, 1000)
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.
await
session
.
patch
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录