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
e7ca6aa4
Unverified
Commit
e7ca6aa4
authored
Apr 05, 2019
by
Joe Haddad
Committed by
GitHub
Apr 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly compute unknown module ids (#6898)
parent
cd9a1085
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
4 deletions
+82
-4
webpack-config.ts
packages/next/build/webpack-config.ts
+1
-1
all-modules-identified-plugin.ts
...xt/build/webpack/plugins/all-modules-identified-plugin.ts
+73
-2
package.json
packages/next/package.json
+2
-0
yarn.lock
yarn.lock
+6
-1
No files found.
packages/next/build/webpack-config.ts
View file @
e7ca6aa4
...
@@ -312,7 +312,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -312,7 +312,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
!
dev
&&
new
webpack
.
HashedModuleIdsPlugin
(),
!
dev
&&
new
webpack
.
HashedModuleIdsPlugin
(),
// This must come after HashedModuleIdsPlugin (it sets any modules that
// This must come after HashedModuleIdsPlugin (it sets any modules that
// were missed by HashedModuleIdsPlugin)
// were missed by HashedModuleIdsPlugin)
!
dev
&&
new
AllModulesIdentifiedPlugin
(
),
!
dev
&&
__selectivePageBuilding
&&
new
AllModulesIdentifiedPlugin
(
dir
),
// This sets chunk ids to be hashed versions of their names to reduce
// This sets chunk ids to be hashed versions of their names to reduce
// bundle churn
// bundle churn
!
dev
&&
new
HashedChunkIdsPlugin
(
buildId
),
!
dev
&&
new
HashedChunkIdsPlugin
(
buildId
),
...
...
packages/next/build/webpack/plugins/all-modules-identified-plugin.ts
View file @
e7ca6aa4
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
createHash
}
from
'crypto'
import
{
createHash
}
from
'crypto'
import
escapeRegex
from
'escape-string-regexp'
import
path
from
'path'
function
getRawModuleIdentifier
(
m
:
any
,
dir
:
string
)
{
// webpack impl:
// new RawModule(
// "/* (ignored) */",
// `ignored ${context} ${request}`,
// `${request} (ignored)`
// )
let
request
=
m
.
readableIdentifierStr
.
replace
(
/
\(
ignored
\)
$/
,
''
)
let
context
=
m
.
identifierStr
.
match
(
new
RegExp
(
`^ignored (.*)
${
escapeRegex
(
request
)}
$`
))
.
pop
()
if
(
path
.
isAbsolute
(
request
))
{
request
=
path
.
relative
(
dir
,
request
)
}
if
(
path
.
isAbsolute
(
context
))
{
context
=
path
.
relative
(
dir
,
context
)
}
const
identifier
=
`
${
context
}
::
${
request
}
`
console
.
warn
(
`[module identifier] RawModule
${
m
.
identifier
()}
=>
${
identifier
}
`
)
return
identifier
}
function
getMultiModuleIdentifier
(
m
:
any
)
{
const
mods
=
m
.
dependencies
.
map
((
d
:
any
)
=>
d
.
module
)
if
(
mods
.
some
((
d
:
any
)
=>
!
Boolean
(
d
)))
{
throw
new
Error
(
'Cannot handle a MultiModule with moduleless dependencies'
)
}
const
ids
=
mods
.
map
((
m
:
any
)
=>
m
.
id
)
if
(
ids
.
some
((
i
:
any
)
=>
!
Boolean
(
i
)))
{
throw
new
Error
(
'Cannot handle a MultiModule dependency without a module id'
)
}
const
identifier
=
ids
.
sort
().
join
(
'::'
)
console
.
warn
(
`[module identifier] MultiModule
${
m
.
identifier
()}
=>
${
identifier
}
`
)
return
identifier
}
export
class
AllModulesIdentifiedPlugin
implements
Plugin
{
export
class
AllModulesIdentifiedPlugin
implements
Plugin
{
private
dir
:
string
constructor
(
dir
:
string
)
{
this
.
dir
=
dir
}
apply
(
compiler
:
Compiler
)
{
apply
(
compiler
:
Compiler
)
{
compiler
.
hooks
.
compilation
.
tap
(
compiler
.
hooks
.
compilation
.
tap
(
'AllModulesIdentifiedPlugin'
,
'AllModulesIdentifiedPlugin'
,
...
@@ -10,11 +65,27 @@ export class AllModulesIdentifiedPlugin implements Plugin {
...
@@ -10,11 +65,27 @@ export class AllModulesIdentifiedPlugin implements Plugin {
'AllModulesIdentifiedPlugin'
,
'AllModulesIdentifiedPlugin'
,
modules
=>
{
modules
=>
{
;(
modules
as
any
[]).
forEach
(
m
=>
{
;(
modules
as
any
[]).
forEach
(
m
=>
{
if
(
m
.
id
!=
null
||
!
m
.
identifier
)
{
if
(
m
.
id
!=
null
)
{
return
return
}
}
const
identifier
=
m
.
identifier
()
let
identifier
:
string
if
(
m
.
constructor
&&
m
.
constructor
.
name
===
'RawModule'
)
{
identifier
=
getRawModuleIdentifier
(
m
,
this
.
dir
)
}
else
if
(
m
.
constructor
&&
m
.
constructor
.
name
===
'MultiModule'
)
{
identifier
=
getMultiModuleIdentifier
(
m
)
}
else
{
throw
new
Error
(
`Do not know how to handle module:
${
m
.
name
}
,
${
m
.
identifier
&&
m
.
identifier
()}
,
${
m
.
type
}
,
${
m
.
constructor
&&
m
.
constructor
.
name
}
`
)
}
// This hashing algorithm is consistent with how the rest of
// This hashing algorithm is consistent with how the rest of
// webpack does it (n.b. HashedModuleIdsPlugin)
// webpack does it (n.b. HashedModuleIdsPlugin)
...
...
packages/next/package.json
View file @
e7ca6aa4
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
"babel-plugin-transform-async-to-promises"
:
"0.8.7"
,
"babel-plugin-transform-async-to-promises"
:
"0.8.7"
,
"babel-plugin-transform-react-remove-prop-types"
:
"0.4.15"
,
"babel-plugin-transform-react-remove-prop-types"
:
"0.4.15"
,
"chalk"
:
"2.4.2"
,
"chalk"
:
"2.4.2"
,
"escape-string-regexp"
:
"1.0.5"
,
"find-cache-dir"
:
"2.0.0"
,
"find-cache-dir"
:
"2.0.0"
,
"find-up"
:
"2.1.0"
,
"find-up"
:
"2.1.0"
,
"fresh"
:
"0.5.2"
,
"fresh"
:
"0.5.2"
,
...
@@ -104,6 +105,7 @@
...
@@ -104,6 +105,7 @@
"@types/babel__template"
:
"7.0.1"
,
"@types/babel__template"
:
"7.0.1"
,
"@types/babel__traverse"
:
"7.0.3"
,
"@types/babel__traverse"
:
"7.0.3"
,
"@types/cross-spawn"
:
"6.0.0"
,
"@types/cross-spawn"
:
"6.0.0"
,
"@types/escape-string-regexp"
:
"1.0.0"
,
"@types/etag"
:
"1.8.0"
,
"@types/etag"
:
"1.8.0"
,
"@types/fresh"
:
"0.5.0"
,
"@types/fresh"
:
"0.5.0"
,
"@types/loader-utils"
:
"1.1.3"
,
"@types/loader-utils"
:
"1.1.3"
,
...
...
yarn.lock
View file @
e7ca6aa4
...
@@ -1571,6 +1571,11 @@
...
@@ -1571,6 +1571,11 @@
dependencies:
dependencies:
"@types/node" "*"
"@types/node" "*"
"@types/escape-string-regexp@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/escape-string-regexp/-/escape-string-regexp-1.0.0.tgz#052d16d87db583b72daceae4eaabddb66954424c"
integrity sha512-KAruqgk9/340M4MYYasdBET+lyYN8KMXUuRKWO72f4SbmIMMFp9nnJiXUkJS0HC2SFe4x0R/fLozXIzqoUfSjA==
"@types/etag@1.8.0":
"@types/etag@1.8.0":
version "1.8.0"
version "1.8.0"
resolved "https://registry.yarnpkg.com/@types/etag/-/etag-1.8.0.tgz#37f0b1f3ea46da7ae319bbedb607e375b4c99f7e"
resolved "https://registry.yarnpkg.com/@types/etag/-/etag-1.8.0.tgz#37f0b1f3ea46da7ae319bbedb607e375b4c99f7e"
...
@@ -4780,7 +4785,7 @@ escape-html@~1.0.3:
...
@@ -4780,7 +4785,7 @@ escape-html@~1.0.3:
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
escape-string-regexp@
1.0.5, escape-string-regexp@
^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
...
...
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