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
a33bb5be
Unverified
Commit
a33bb5be
authored
Jul 17, 2020
by
Tim Neutkens
Committed by
GitHub
Jul 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix app-document-import-order test for webpack 5 (#15224)
parent
56d62a52
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
27 additions
and
30 deletions
+27
-30
package.json
package.json
+1
-1
entries.ts
packages/next/build/entries.ts
+1
-1
webpack-config.ts
packages/next/build/webpack-config.ts
+9
-12
page-loader.js
packages/next/client/page-loader.js
+1
-1
constants.ts
packages/next/next-server/lib/constants.ts
+5
-6
get-route-from-entrypoint.ts
...ages/next/next-server/server/get-route-from-entrypoint.ts
+0
-2
hot-reloader.ts
packages/next/server/hot-reloader.ts
+1
-1
on-demand-entry-handler.ts
packages/next/server/on-demand-entry-handler.ts
+1
-1
webpack.d.ts
packages/next/types/webpack.d.ts
+1
-0
next.config.js
test/integration/app-document-import-order/next.config.js
+2
-0
index.test.js
test/integration/build-output/test/index.test.js
+4
-4
index.test.js
test/integration/dist-dir/test/index.test.js
+1
-1
No files found.
package.json
View file @
a33bb5be
...
...
@@ -33,7 +33,7 @@
"publish-stable"
:
"lerna version --force-publish"
,
"lint-staged"
:
"lint-staged"
,
"next"
:
"node packages/next/dist/bin/next"
,
"debug"
:
"node --inspect
-brk
packages/next/dist/bin/next"
"debug"
:
"node --inspect packages/next/dist/bin/next"
},
"pre-commit"
:
"lint-staged"
,
"devDependencies"
:
{
...
...
packages/next/build/entries.ts
View file @
a33bb5be
...
...
@@ -103,7 +103,7 @@ export function createEntrypoints(
const
bundleFile
=
normalizePagePath
(
page
)
const
isApiRoute
=
page
.
match
(
API_ROUTE
)
const
clientBundlePath
=
posix
.
join
(
'
static'
,
'
pages'
,
bundleFile
)
const
clientBundlePath
=
posix
.
join
(
'pages'
,
bundleFile
)
const
serverBundlePath
=
posix
.
join
(
'pages'
,
bundleFile
)
const
isLikeServerless
=
isTargetLikeServerless
(
target
)
...
...
packages/next/build/webpack-config.ts
View file @
a33bb5be
...
...
@@ -134,9 +134,7 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } {
}
type
ClientEntries
=
{
'main.js'
:
string
[]
}
&
{
[
key
:
string
]:
string
[
key
:
string
]:
string
|
string
[]
}
export
default
async
function
getBaseWebpackConfig
(
...
...
@@ -432,7 +430,6 @@ export default async function getBaseWebpackConfig(
shared
:
{
name
(
module
,
chunks
)
{
return
(
(
isWebpack5
?
'static/chunks/'
:
''
)
+
crypto
.
createHash
(
'sha1'
)
.
update
(
...
...
@@ -443,8 +440,7 @@ export default async function getBaseWebpackConfig(
''
)
)
.
digest
(
'hex'
)
+
(
isModuleCSS
(
module
)
?
'_CSS'
:
''
)
.
digest
(
'hex'
)
+
(
isModuleCSS
(
module
)
?
'_CSS'
:
''
)
)
},
priority
:
10
,
...
...
@@ -713,7 +709,9 @@ export default async function getBaseWebpackConfig(
output
:
{
path
:
outputPath
,
// On the server we don't use the chunkhash
filename
:
dev
||
isServer
?
'[name].js'
:
'[name]-[chunkhash].js'
,
filename
:
isServer
?
'[name].js'
:
`static/chunks/[name]
${
dev
?
''
:
'-[chunkhash]'
}
.js`
,
library
:
isServer
?
undefined
:
'_N_E'
,
libraryTarget
:
isServer
?
'commonjs2'
:
'assign'
,
hotUpdateChunkFilename
:
isWebpack5
...
...
@@ -1277,11 +1275,10 @@ export default async function getBaseWebpackConfig(
:
originalEntry
// Server compilation doesn't have main.js
if
(
clientEntries
&&
entry
[
'main.js'
]
&&
entry
[
'main.js'
].
length
>
0
)
{
const
originalFile
=
clientEntries
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
entry
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
=
[
...
entry
[
'main.js'
],
originalFile
,
]
const
originalFile
=
clientEntries
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
as
string
entry
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
=
[...[
'main.js'
],
originalFile
]
}
delete
entry
[
'main.js'
]
...
...
packages/next/client/page-loader.js
View file @
a33bb5be
...
...
@@ -252,7 +252,7 @@ export default class PageLoader {
route
=
normalizeRoute
(
route
)
let
scriptRoute
=
getAssetPathFromRoute
(
route
,
'.js'
)
const
url
=
`
${
this
.
assetPrefix
}
/_next/static/pages
${
encodeURI
(
const
url
=
`
${
this
.
assetPrefix
}
/_next/static/
chunks/
pages
${
encodeURI
(
scriptRoute
)}
`
this
.
loadScript
(
url
,
route
)
...
...
packages/next/next-server/lib/constants.ts
View file @
a33bb5be
...
...
@@ -19,17 +19,16 @@ export const CLIENT_STATIC_FILES_PATH = 'static'
export
const
CLIENT_STATIC_FILES_RUNTIME
=
'runtime'
export
const
AMP_RENDER_TARGET
=
'__NEXT_AMP_RENDER_TARGET__'
export
const
STRING_LITERAL_DROP_BUNDLE
=
'__NEXT_DROP_CLIENT_FILE__'
export
const
CLIENT_STATIC_FILES_RUNTIME_PATH
=
`
${
CLIENT_STATIC_FILES_PATH
}
/
${
CLIENT_STATIC_FILES_RUNTIME
}
`
// static/runtime/main.js
export
const
CLIENT_STATIC_FILES_RUNTIME_MAIN
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/
main`
export
const
CLIENT_STATIC_FILES_RUNTIME_MAIN
=
`main`
// static/runtime/react-refresh.js
export
const
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/
react-refresh`
export
const
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH
=
`react-refresh`
// static/runtime/amp.js
export
const
CLIENT_STATIC_FILES_RUNTIME_AMP
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/
amp`
export
const
CLIENT_STATIC_FILES_RUNTIME_AMP
=
`amp`
// static/runtime/webpack.js
export
const
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/
webpack`
export
const
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
=
`webpack`
// static/runtime/polyfills.js
export
const
CLIENT_STATIC_FILES_RUNTIME_POLYFILLS
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/
polyfills`
export
const
CLIENT_STATIC_FILES_RUNTIME_POLYFILLS
=
`polyfills`
export
const
TEMPORARY_REDIRECT_STATUS
=
307
export
const
PERMANENT_REDIRECT_STATUS
=
308
export
const
STATIC_PROPS_ID
=
'__N_SSG'
...
...
packages/next/next-server/server/get-route-from-entrypoint.ts
View file @
a33bb5be
import
getRouteFromAssetPath
from
'../lib/router/utils/get-route-from-asset-path'
// matches static/<buildid>/pages/:page*.js
// const SERVER_ROUTE_NAME_REGEX = /^static[/\\][^/\\]+[/\\]pages[/\\](.*)$/
// matches pages/:page*.js
const
SERVER_ROUTE_NAME_REGEX
=
/^pages
[/\\](
.*
)
$/
// matches static/pages/:page*.js
...
...
packages/next/server/hot-reloader.ts
View file @
a33bb5be
...
...
@@ -84,7 +84,7 @@ function addCorsSupport(req: IncomingMessage, res: ServerResponse) {
}
const
matchNextPageBundleRequest
=
route
(
'/_next/static/pages/:path*.js(
\\
.map|)'
'/_next/static/
chunks/
pages/:path*.js(
\\
.map|)'
)
// Recursively look up the issuer till it ends up at the root
...
...
packages/next/server/on-demand-entry-handler.ts
View file @
a33bb5be
...
...
@@ -168,7 +168,7 @@ export default function onDemandEntryHandler(
const
bundleFile
=
normalizePagePath
(
pageUrl
)
const
serverBundlePath
=
posix
.
join
(
'pages'
,
bundleFile
)
const
clientBundlePath
=
posix
.
join
(
'
static'
,
'
pages'
,
bundleFile
)
const
clientBundlePath
=
posix
.
join
(
'pages'
,
bundleFile
)
const
absolutePagePath
=
pagePath
.
startsWith
(
'next/dist/pages'
)
?
require
.
resolve
(
pagePath
)
:
join
(
pagesDir
,
pagePath
)
...
...
packages/next/types/webpack.d.ts
View file @
a33bb5be
...
...
@@ -699,6 +699,7 @@ declare module 'webpack' {
reuseExistingChunk
?:
boolean
/** Give chunks created a name (chunks with equal name are merged) */
name
?:
boolean
|
string
|
((...
args
:
any
[])
=>
any
)
filename
?:
string
}
interface
SplitChunksOptions
{
/** Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML) */
...
...
test/integration/app-document-import-order/next.config.js
View file @
a33bb5be
...
...
@@ -17,6 +17,7 @@ module.exports = {
enforce
:
true
,
priority
:
10
,
chunks
:
'all'
,
filename
:
'static/chunks/[name].[chunkhash].js'
,
},
requiredByPage
:
{
test
:
/requiredByPage.js/
,
...
...
@@ -24,6 +25,7 @@ module.exports = {
enforce
:
true
,
priority
:
10
,
chunks
:
'all'
,
filename
:
'static/chunks/[name].[chunkhash].js'
,
},
},
},
...
...
test/integration/build-output/test/index.test.js
View file @
a33bb5be
...
...
@@ -26,7 +26,7 @@ describe('Build Output', () => {
expect
(
stdout
).
toMatch
(
/
\/
[
]
*
\d{1,}
B/
)
expect
(
stdout
).
toMatch
(
/
\+
First Load JS shared by all
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
runtime
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
chunks
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/ chunks
\/
framework
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
not
.
toContain
(
' /_document'
)
...
...
@@ -149,7 +149,7 @@ describe('Build Output', () => {
expect
(
stdout
).
toMatch
(
/
\/
[
]
*
\d{1,}
B/
)
expect
(
stdout
).
toMatch
(
/
\/
_app
[
]
*
\d{1,}
B/
)
expect
(
stdout
).
toMatch
(
/
\+
First Load JS shared by all
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
runtime
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
chunks
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/ chunks
\/
framework
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
not
.
toContain
(
' /_document'
)
...
...
@@ -177,7 +177,7 @@ describe('Build Output', () => {
expect
(
stdout
).
toMatch
(
/
\/
amp .* AMP/
)
expect
(
stdout
).
toMatch
(
/
\/
hybrid
[
0-9.
]
* B/
)
expect
(
stdout
).
toMatch
(
/
\+
First Load JS shared by all
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
runtime
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
chunks
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/ chunks
\/
framework
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
not
.
toContain
(
' /_document'
)
...
...
@@ -203,7 +203,7 @@ describe('Build Output', () => {
expect
(
stdout
).
toMatch
(
/
\/
[
]
*
\d{1,}
B/
)
expect
(
stdout
).
toMatch
(
/λ
\/
404
[
]
*
\d{1,}
B/
)
expect
(
stdout
).
toMatch
(
/
\+
First Load JS shared by all
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
runtime
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/
chunks
\/
main
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
toMatch
(
/ chunks
\/
framework
\.[
0-9a-z
]{6}\.
js
[
0-9.
]
* kB/
)
expect
(
stdout
).
not
.
toContain
(
' /_document'
)
...
...
test/integration/dist-dir/test/index.test.js
View file @
a33bb5be
...
...
@@ -17,7 +17,7 @@ const nextConfig = join(appDir, 'next.config.js')
let
appPort
let
app
describe
(
'
Production Usage
'
,
()
=>
{
describe
(
'
distDir
'
,
()
=>
{
describe
(
'With basic usage'
,
()
=>
{
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
...
...
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