Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
74398d09
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,发现更多精彩内容 >>
未验证
提交
74398d09
编写于
5月 09, 2019
作者:
J
Joe Haddad
提交者:
GitHub
5月 09, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Separate shared shuttle modules (#7287)
* Separate shared shuttle modules * Correct types
上级
92cbe13b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
21 deletion
+32
-21
packages/next/build/flying-shuttle.ts
packages/next/build/flying-shuttle.ts
+24
-15
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
+8
-6
未找到文件。
packages/next/build/flying-shuttle.ts
浏览文件 @
74398d09
...
...
@@ -20,6 +20,7 @@ const fsWriteFile = promisify(fs.writeFile)
const
fsCopyFile
=
promisify
(
fs
.
copyFile
)
type
ChunkGraphManifest
=
{
sharedFiles
:
string
[]
|
undefined
pages
:
{
[
page
:
string
]:
string
[]
}
pageChunks
:
{
[
page
:
string
]:
string
[]
}
chunks
:
{
[
page
:
string
]:
string
[]
}
...
...
@@ -32,11 +33,12 @@ export class FlyingShuttle {
private
buildId
:
string
private
pagesDirectory
:
string
private
distDirectory
:
string
private
c
acheIdentifier
:
string
private
parentC
acheIdentifier
:
string
private
_shuttleBuildId
:
string
|
undefined
private
_restoreSema
=
new
Sema
(
1
)
private
_recalledManifest
:
ChunkGraphManifest
=
{
sharedFiles
:
[],
pages
:
{},
pageChunks
:
{},
chunks
:
{},
...
...
@@ -65,7 +67,7 @@ export class FlyingShuttle {
this
.
buildId
=
buildId
this
.
pagesDirectory
=
pagesDirectory
this
.
distDirectory
=
distDirectory
this
.
c
acheIdentifier
=
cacheIdentifier
this
.
parentC
acheIdentifier
=
cacheIdentifier
}
hasShuttle
=
async
()
=>
{
...
...
@@ -100,9 +102,9 @@ export class FlyingShuttle {
const
manifestPath
=
path
.
join
(
this
.
shuttleDirectory
,
CHUNK_GRAPH_MANIFEST
)
const
manifest
=
require
(
manifestPath
)
as
ChunkGraphManifest
const
{
pages
:
pageFileDictionary
,
hashes
}
=
manifest
const
{
sharedFiles
,
pages
:
pageFileDictionary
,
hashes
}
=
manifest
const
pageNames
=
Object
.
keys
(
pageFileDictionary
)
const
allFiles
=
new
Set
()
const
allFiles
=
new
Set
(
sharedFiles
)
pageNames
.
forEach
(
pageName
=>
pageFileDictionary
[
pageName
].
forEach
(
file
=>
allFiles
.
add
(
file
))
)
...
...
@@ -118,23 +120,28 @@ export class FlyingShuttle {
const
hash
=
crypto
.
createHash
(
'
sha1
'
)
.
update
(
this
.
c
acheIdentifier
)
.
update
(
this
.
parentC
acheIdentifier
)
.
update
(
await
fsReadFile
(
filePath
))
.
digest
(
'
hex
'
)
fileChanged
.
set
(
file
,
hash
!==
hashes
[
file
])
})
)
const
unchangedPages
=
pageNames
.
filter
(
p
=>
!
pageFileDictionary
[
p
].
map
(
f
=>
fileChanged
.
get
(
f
)).
some
(
Boolean
)
)
.
filter
(
pageName
=>
pageName
!==
'
/_app
'
&&
pageName
!==
'
/_error
'
&&
pageName
!==
'
/_document
'
)
const
unchangedPages
=
(
sharedFiles
||
[])
.
map
(
f
=>
fileChanged
.
get
(
f
))
.
some
(
Boolean
)
?
[]
:
pageNames
.
filter
(
p
=>
!
pageFileDictionary
[
p
].
map
(
f
=>
fileChanged
.
get
(
f
)).
some
(
Boolean
)
)
.
filter
(
pageName
=>
pageName
!==
'
/_app
'
&&
pageName
!==
'
/_error
'
&&
pageName
!==
'
/_document
'
)
if
(
unchangedPages
.
length
)
{
const
u
=
unchangedPages
.
length
...
...
@@ -254,6 +261,8 @@ export class FlyingShuttle {
)
as
ChunkGraphManifest
const
storeManifest
:
ChunkGraphManifest
=
{
// Intentionally does not merge with the recalled manifest
sharedFiles
:
nextManifest
.
sharedFiles
,
pages
:
Object
.
assign
(
{},
this
.
_recalledManifest
.
pages
,
...
...
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
浏览文件 @
74398d09
...
...
@@ -8,10 +8,12 @@ import { Compiler, Plugin } from 'webpack'
type
StringDictionary
=
{
[
pageName
:
string
]:
string
[]
}
const
manifest
:
{
sharedFiles
:
string
[]
pages
:
StringDictionary
pageChunks
:
StringDictionary
chunks
:
StringDictionary
}
=
{
sharedFiles
:
[],
pages
:
{},
pageChunks
:
{},
chunks
:
{},
...
...
@@ -90,7 +92,7 @@ export function exportManifest({
hashes
:
{}
as
{
[
pageName
:
string
]:
string
},
}
const
allFiles
=
new
Set
<
string
>
()
const
allFiles
=
new
Set
<
string
>
(
manifest
.
sharedFiles
)
for
(
const
page
of
Object
.
keys
(
finalManifest
.
pages
))
{
finalManifest
.
pages
[
page
].
forEach
(
f
=>
allFiles
.
add
(
f
))
}
...
...
@@ -283,13 +285,13 @@ export class ChunkGraphPlugin implements Plugin {
.
replace
(
/
[
.
]
js$/
,
`.
${
this
.
buildId
}
.js`
)
:
name
manifest
.
sharedFiles
=
[
...
new
Set
([...(
manifest
.
sharedFiles
||
[]),
...
sharedFiles
]),
].
sort
()
for
(
const
page
in
pages
)
{
manifest
.
pages
[
page
]
=
[
...
new
Set
([
...(
manifest
.
pages
[
page
]
||
[]),
...
pages
[
page
],
...
sharedFiles
,
]),
...
new
Set
([...(
manifest
.
pages
[
page
]
||
[]),
...
pages
[
page
]]),
].
sort
()
// There's no chunks to save from serverless bundles
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录