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
33d32eab
Unverified
Commit
33d32eab
authored
Apr 07, 2019
by
Joe Haddad
Committed by
GitHub
Apr 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make chunk graph more accurate (#6923)
* Make chunk graph more accurate * Include shared files in every page
parent
54f21e98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
index.ts
packages/next/build/index.ts
+4
-5
chunk-graph-plugin.ts
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
+17
-8
No files found.
packages/next/build/index.ts
View file @
33d32eab
...
@@ -46,12 +46,11 @@ function flatten<T>(arr: T[][]): T[] {
...
@@ -46,12 +46,11 @@ function flatten<T>(arr: T[][]): T[] {
}
}
function
getPossibleFiles
(
pageExtensions
:
string
[],
pages
:
string
[])
{
function
getPossibleFiles
(
pageExtensions
:
string
[],
pages
:
string
[])
{
const
res
=
pages
.
map
(
page
=>
{
const
res
=
pages
.
map
(
page
=>
const
pi
=
path
.
join
(
page
,
'index'
)
[
page
]
return
[
page
,
pi
]
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
page
}
.
${
e
}
`
))
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
page
}
.
${
e
}
`
))
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
p
i
}
.
${
e
}
`
))
.
concat
(
pageExtensions
.
map
(
e
=>
`
${
p
ath
.
join
(
page
,
'index'
)
}
.
${
e
}
`
))
}
)
)
return
flatten
<
string
>
(
res
)
return
flatten
<
string
>
(
res
)
}
}
...
...
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
View file @
33d32eab
...
@@ -77,8 +77,8 @@ export class ChunkGraphPlugin implements Plugin {
...
@@ -77,8 +77,8 @@ export class ChunkGraphPlugin implements Plugin {
hashes
:
{},
hashes
:
{},
}
}
let
clientRuntime
=
[]
as
string
[]
const
sharedFiles
=
[]
as
string
[]
let
clientRuntime
Chunks
=
[]
as
string
[]
const
shared
Chunks
=
[]
as
string
[]
const
pages
:
StringDictionary
=
{}
const
pages
:
StringDictionary
=
{}
const
pageChunks
:
StringDictionary
=
{}
const
pageChunks
:
StringDictionary
=
{}
const
allFiles
=
new
Set
()
const
allFiles
=
new
Set
()
...
@@ -139,12 +139,21 @@ export class ChunkGraphPlugin implements Plugin {
...
@@ -139,12 +139,21 @@ export class ChunkGraphPlugin implements Plugin {
}
}
if
(
pageName
)
{
if
(
pageName
)
{
pages
[
pageName
]
=
files
if
(
pageChunks
[
pageName
]
=
[...
involvedChunks
]
pageName
===
'/_app'
||
pageName
===
'/_error'
||
pageName
===
'/_document'
)
{
sharedFiles
.
push
(...
files
)
sharedChunks
.
push
(...
involvedChunks
)
}
else
{
pages
[
pageName
]
=
files
pageChunks
[
pageName
]
=
[...
involvedChunks
]
}
}
else
{
}
else
{
if
(
chunk
.
name
===
CLIENT_STATIC_FILES_RUNTIME_MAIN
)
{
if
(
chunk
.
name
===
CLIENT_STATIC_FILES_RUNTIME_MAIN
)
{
clientRuntime
=
files
sharedFiles
.
push
(...
files
)
clientRuntimeChunks
=
[...
involvedChunks
]
sharedChunks
.
push
(...
involvedChunks
)
}
else
{
}
else
{
manifest
.
chunks
[
chunk
.
name
]
=
files
manifest
.
chunks
[
chunk
.
name
]
=
files
}
}
...
@@ -152,7 +161,7 @@ export class ChunkGraphPlugin implements Plugin {
...
@@ -152,7 +161,7 @@ export class ChunkGraphPlugin implements Plugin {
})
})
for
(
const
page
in
pages
)
{
for
(
const
page
in
pages
)
{
manifest
.
pages
[
page
]
=
[...
pages
[
page
],
...
clientRuntime
]
manifest
.
pages
[
page
]
=
[...
pages
[
page
],
...
sharedFiles
]
manifest
.
pageChunks
[
page
]
=
[
manifest
.
pageChunks
[
page
]
=
[
...
new
Set
([
...
new
Set
([
...
pageChunks
[
page
],
...
pageChunks
[
page
],
...
@@ -163,7 +172,7 @@ export class ChunkGraphPlugin implements Plugin {
...
@@ -163,7 +172,7 @@ export class ChunkGraphPlugin implements Plugin {
.
replace
(
/
[
.
]
js$/
,
`.
${
this
.
buildId
}
.js`
)
.
replace
(
/
[
.
]
js$/
,
`.
${
this
.
buildId
}
.js`
)
:
name
:
name
),
),
...
clientRuntime
Chunks
,
...
shared
Chunks
,
]),
]),
].
sort
()
].
sort
()
}
}
...
...
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