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
e57b2091
Unverified
Commit
e57b2091
authored
Jul 20, 2020
by
Tim Neutkens
Committed by
GitHub
Jul 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring over fixes from #15185 (#15326)
Co-authored-by:
Joe Haddad
<
joe.haddad@zeit.co
>
parent
a26c69d1
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
76 additions
and
91 deletions
+76
-91
webpack-config.ts
packages/next/build/webpack-config.ts
+2
-1
next-drop-client-page-plugin.ts
...ext/build/webpack/plugins/next-drop-client-page-plugin.ts
+1
-0
amp-dev.js
packages/next/client/dev/amp-dev.js
+5
-1
ReactRefreshWebpackPlugin.ts
packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
+1
-0
loader.ts
packages/react-refresh-utils/loader.ts
+4
-1
index.test.js
test/integration/css-client-nav/test/index.test.js
+2
-1
index.test.js
test/integration/dynamic-routing/test/index.test.js
+2
-1
index.test.js
test/integration/legacy-sass/test/index.test.js
+9
-2
index.test.js
test/integration/modern-mode/test/index.test.js
+2
-1
index.test.js
...integration/no-duplicate-compile-error/test/index.test.js
+1
-1
index.test.js
test/integration/profiling/test/index.test.js
+2
-1
next.config.js
test/integration/typescript-ignore-errors/next.config.js
+0
-3
index.tsx
test/integration/typescript-ignore-errors/pages/index.tsx
+1
-1
index.test.js
test/integration/typescript-ignore-errors/test/index.test.js
+34
-72
index.test.js
test/integration/worker-loader/test/index.test.js
+2
-1
next-test-utils.js
test/lib/next-test-utils.js
+8
-4
No files found.
packages/next/build/webpack-config.ts
View file @
e57b2091
...
@@ -944,7 +944,8 @@ export default async function getBaseWebpackConfig(
...
@@ -944,7 +944,8 @@ export default async function getBaseWebpackConfig(
new
ProfilingPlugin
({
new
ProfilingPlugin
({
tracer
,
tracer
,
}),
}),
config
.
experimental
.
modern
&&
!
isWebpack5
&&
config
.
experimental
.
modern
&&
!
isServer
&&
!
isServer
&&
!
dev
&&
!
dev
&&
(()
=>
{
(()
=>
{
...
...
packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
View file @
e57b2091
...
@@ -102,6 +102,7 @@ export class DropClientPage implements Plugin {
...
@@ -102,6 +102,7 @@ export class DropClientPage implements Plugin {
// @ts-ignore TODO: webpack 5 types
// @ts-ignore TODO: webpack 5 types
const
module
=
compilation
.
moduleGraph
.
getModule
(
dependency
)
const
module
=
compilation
.
moduleGraph
.
getModule
(
dependency
)
if
(
module
?.
buildInfo
?.
NEXT_ampFirst
)
{
if
(
module
?.
buildInfo
?.
NEXT_ampFirst
)
{
ampFirstEntryNamesItem
.
push
(
name
)
// @ts-ignore @types/webpack has outdated types for webpack 5
// @ts-ignore @types/webpack has outdated types for webpack 5
compilation
.
entries
.
delete
(
name
)
compilation
.
entries
.
delete
(
name
)
}
}
...
...
packages/next/client/dev/amp-dev.js
View file @
e57b2091
...
@@ -41,7 +41,11 @@ async function tryApplyUpdates() {
...
@@ -41,7 +41,11 @@ async function tryApplyUpdates() {
const
res
=
await
fetch
(
`
${
hotUpdatePath
}${
curHash
}
.hot-update.json`
)
const
res
=
await
fetch
(
`
${
hotUpdatePath
}${
curHash
}
.hot-update.json`
)
const
jsonData
=
await
res
.
json
()
const
jsonData
=
await
res
.
json
()
const
curPage
=
page
===
'/'
?
'index'
:
page
const
curPage
=
page
===
'/'
?
'index'
:
page
const
pageUpdated
=
Object
.
keys
(
jsonData
.
c
).
some
((
mod
)
=>
{
// webpack 5 uses an array instead
const
pageUpdated
=
(
Array
.
isArray
(
jsonData
.
c
)
?
jsonData
.
c
:
Object
.
keys
(
jsonData
.
c
)
).
some
((
mod
)
=>
{
return
(
return
(
mod
.
indexOf
(
mod
.
indexOf
(
`pages
${
curPage
.
substr
(
0
,
1
)
===
'/'
?
curPage
:
`/
${
curPage
}
`
}
`
`pages
${
curPage
.
substr
(
0
,
1
)
===
'/'
?
curPage
:
`/
${
curPage
}
`
}
`
...
...
packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
View file @
e57b2091
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
// @ts-ignore exists in webpack 5
// @ts-ignore exists in webpack 5
RuntimeGlobals
,
RuntimeGlobals
,
version
,
version
,
// @ts-ignore exists in webpack 5
compilation
as
Compilation
,
compilation
as
Compilation
,
}
from
'webpack'
}
from
'webpack'
...
...
packages/react-refresh-utils/loader.ts
View file @
e57b2091
import
{
loader
}
from
'webpack'
import
{
// @ts-ignore exists in webpack 5
loader
,
}
from
'webpack'
import
RefreshModuleRuntime
from
'./internal/ReactRefreshModule.runtime'
import
RefreshModuleRuntime
from
'./internal/ReactRefreshModule.runtime'
let
refreshModuleRuntime
=
RefreshModuleRuntime
.
toString
()
let
refreshModuleRuntime
=
RefreshModuleRuntime
.
toString
()
...
...
test/integration/css-client-nav/test/index.test.js
View file @
e57b2091
...
@@ -172,7 +172,8 @@ describe('CSS Module client-side navigation in Production', () => {
...
@@ -172,7 +172,8 @@ describe('CSS Module client-side navigation in Production', () => {
})
})
})
})
describe
(
'CSS Module client-side navigation in Production (Modern)'
,
()
=>
{
// TODO: Make webpack 5 work with nest-esm-plugin
describe
.
skip
(
'CSS Module client-side navigation in Production (Modern)'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'multi-module-modern'
)
const
appDir
=
join
(
fixturesDir
,
'multi-module-modern'
)
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
...
...
test/integration/dynamic-routing/test/index.test.js
View file @
e57b2091
...
@@ -519,7 +519,8 @@ function runTests(dev) {
...
@@ -519,7 +519,8 @@ function runTests(dev) {
}
}
})
})
}
else
{
}
else
{
it
(
'should output modern bundles with dynamic route correctly'
,
async
()
=>
{
// TODO: Make webpack 5 work with nest-esm-plugin
it
.
skip
(
'should output modern bundles with dynamic route correctly'
,
async
()
=>
{
const
buildManifest
=
require
(
join
(
'../.next'
,
'build-manifest.json'
))
const
buildManifest
=
require
(
join
(
'../.next'
,
'build-manifest.json'
))
const
files
=
buildManifest
.
pages
[
const
files
=
buildManifest
.
pages
[
...
...
test/integration/legacy-sass/test/index.test.js
View file @
e57b2091
...
@@ -5,12 +5,19 @@ import { findPort, killApp, launchApp, nextBuild } from 'next-test-utils'
...
@@ -5,12 +5,19 @@ import { findPort, killApp, launchApp, nextBuild } from 'next-test-utils'
import
webdriver
from
'next-webdriver'
import
webdriver
from
'next-webdriver'
import
{
recursiveReadDir
}
from
'next/dist/lib/recursive-readdir'
import
{
recursiveReadDir
}
from
'next/dist/lib/recursive-readdir'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
version
}
from
'webpack'
const
isWebpack5
=
parseInt
(
version
)
===
5
jest
.
setTimeout
(
1000
*
60
*
1
)
jest
.
setTimeout
(
1000
*
60
*
1
)
const
appDir
=
join
(
__dirname
,
'../'
)
const
appDir
=
join
(
__dirname
,
'../'
)
describe
(
'Legacy Sass Support Should Disable New CSS'
,
()
=>
{
// TODO: Make legacy Sass support work with webpack 5
const
describeFn
=
isWebpack5
?
describe
.
skip
:
describe
// TODO: Make legacy Sass support work with webpack 5
describeFn
(
'Legacy Sass Support Should Disable New CSS'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
await
remove
(
join
(
appDir
,
'.next'
))
await
nextBuild
(
appDir
)
await
nextBuild
(
appDir
)
...
@@ -26,7 +33,7 @@ describe('Legacy Sass Support Should Disable New CSS', () => {
...
@@ -26,7 +33,7 @@ describe('Legacy Sass Support Should Disable New CSS', () => {
})
})
})
})
describe
(
'Legacy Sass Support should work in development'
,
()
=>
{
describe
Fn
(
'Legacy Sass Support should work in development'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
await
remove
(
join
(
appDir
,
'.next'
))
})
})
...
...
test/integration/modern-mode/test/index.test.js
View file @
e57b2091
...
@@ -19,7 +19,8 @@ let appDir = join(__dirname, '..')
...
@@ -19,7 +19,8 @@ let appDir = join(__dirname, '..')
let
server
let
server
let
appPort
let
appPort
describe
(
'Modern Mode'
,
()
=>
{
// TODO: Make webpack 5 work with nest-esm-plugin
describe
.
skip
(
'Modern Mode'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
await
runNextCommand
([
'build'
],
{
await
runNextCommand
([
'build'
],
{
cwd
:
appDir
,
cwd
:
appDir
,
...
...
test/integration/no-duplicate-compile-error/test/index.test.js
View file @
e57b2091
...
@@ -15,7 +15,7 @@ jest.setTimeout(1000 * 60 * 3)
...
@@ -15,7 +15,7 @@ jest.setTimeout(1000 * 60 * 3)
const
appDir
=
join
(
__dirname
,
'../'
)
const
appDir
=
join
(
__dirname
,
'../'
)
describe
(
'no duplicate compile error output'
,
()
=>
{
describe
(
'no duplicate compile error output'
,
()
=>
{
it
(
'sho
w
not show compile error on page refresh'
,
async
()
=>
{
it
(
'sho
uld
not show compile error on page refresh'
,
async
()
=>
{
let
stdout
=
''
let
stdout
=
''
let
stderr
=
''
let
stderr
=
''
...
...
test/integration/profiling/test/index.test.js
View file @
e57b2091
...
@@ -7,7 +7,8 @@ const appDir = join(__dirname, '../')
...
@@ -7,7 +7,8 @@ const appDir = join(__dirname, '../')
const
profileEventsPath
=
join
(
appDir
,
'.next'
,
'profile-events.json'
)
const
profileEventsPath
=
join
(
appDir
,
'.next'
,
'profile-events.json'
)
jest
.
setTimeout
(
1000
*
60
*
5
)
jest
.
setTimeout
(
1000
*
60
*
5
)
describe
(
'Profiling Usage'
,
()
=>
{
// TODO: Make profiling experimental flag work with webpack 5
describe
.
skip
(
'Profiling Usage'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
// Delete file if it already exists
// Delete file if it already exists
if
(
await
fs
.
existsSync
(
profileEventsPath
))
if
(
await
fs
.
existsSync
(
profileEventsPath
))
...
...
test/integration/typescript-ignore-errors/next.config.js
deleted
100644 → 0
View file @
a26c69d1
module
.
exports
=
{
experimental
:
{
modern
:
true
},
}
test/integration/typescript-ignore-errors/pages/index.tsx
View file @
e57b2091
// Below type error is intentional, it helps check typescript → ignore
DevErrors / ignore
BuildErrors flags in next.config.js
// Below type error is intentional, it helps check typescript → ignoreBuildErrors flags in next.config.js
export
default
():
boolean
=>
'Index page'
export
default
():
boolean
=>
'Index page'
test/integration/typescript-ignore-errors/test/index.test.js
View file @
e57b2091
/* eslint-env jest */
/* eslint-env jest */
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
import
{
nextBuild
,
File
}
from
'next-test-utils'
renderViaHTTP
,
nextBuild
,
findPort
,
launchApp
,
killApp
,
File
,
}
from
'next-test-utils'
jest
.
setTimeout
(
1000
*
60
*
2
)
jest
.
setTimeout
(
1000
*
60
*
2
)
...
@@ -18,71 +11,40 @@ const nextConfigFile = new File(join(appDir, 'next.config.js'))
...
@@ -18,71 +11,40 @@ const nextConfigFile = new File(join(appDir, 'next.config.js'))
describe
(
'TypeScript with error handling options'
,
()
=>
{
describe
(
'TypeScript with error handling options'
,
()
=>
{
// Dev can no longer show errors (for now), logbox will cover this in the
// Dev can no longer show errors (for now), logbox will cover this in the
// future.
// future.
for
(
const
ignoreDevErrors
of
[
/*false,*/
true
])
{
for
(
const
ignoreBuildErrors
of
[
false
,
true
])
{
for
(
const
ignoreBuildErrors
of
[
false
,
true
])
{
describe
(
`ignoreBuildErrors:
${
ignoreBuildErrors
}
`
,
()
=>
{
describe
(
`ignoreDevErrors:
${
ignoreDevErrors
}
, ignoreBuildErrors:
${
ignoreBuildErrors
}
`
,
()
=>
{
beforeAll
(()
=>
{
beforeAll
(()
=>
{
const
nextConfig
=
{
const
nextConfig
=
{
typescript
:
{
ignoreBuildErrors
},
experimental
:
{
modern
:
true
},
}
typescript
:
{
ignoreDevErrors
,
ignoreBuildErrors
},
nextConfigFile
.
write
(
'module.exports = '
+
JSON
.
stringify
(
nextConfig
))
}
})
nextConfigFile
.
write
(
'module.exports = '
+
JSON
.
stringify
(
nextConfig
))
afterAll
(()
=>
{
})
nextConfigFile
.
restore
()
afterAll
(()
=>
{
})
nextConfigFile
.
restore
()
})
it
(
ignoreDevErrors
?
'Next renders the page in dev despite type errors'
:
'Next dev does not render the page in dev because of type errors'
,
async
()
=>
{
let
app
let
output
=
''
try
{
const
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
,
{
onStdout
:
(
msg
)
=>
(
output
+=
msg
),
onStderr
:
(
msg
)
=>
(
output
+=
msg
),
})
await
renderViaHTTP
(
appPort
,
''
)
if
(
ignoreDevErrors
)
{
expect
(
output
).
not
.
toContain
(
'waiting for typecheck results...'
)
expect
(
output
).
not
.
toContain
(
"not assignable to type 'boolean'"
)
}
else
{
expect
(
output
).
toContain
(
'waiting for typecheck results...'
)
expect
(
output
).
toContain
(
"not assignable to type 'boolean'"
)
}
}
finally
{
await
killApp
(
app
)
}
}
)
it
(
ignoreBuildErrors
?
'Next builds the application despite type errors'
:
'Next fails to build the application despite type errors'
,
async
()
=>
{
const
{
stdout
,
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stdout
:
true
,
stderr
:
true
,
})
if
(
ignoreBuildErrors
)
{
it
(
expect
(
stdout
).
toContain
(
'Compiled successfully'
)
ignoreBuildErrors
expect
(
stderr
).
not
.
toContain
(
'Failed to compile.'
)
?
'Next builds the application despite type errors'
expect
(
stderr
).
not
.
toContain
(
"not assignable to type 'boolean'"
)
:
'Next fails to build the application despite type errors'
,
}
else
{
async
()
=>
{
expect
(
stdout
).
not
.
toContain
(
'Compiled successfully'
)
const
{
stdout
,
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
expect
(
stderr
).
toContain
(
'Failed to compile.'
)
stdout
:
true
,
expect
(
stderr
).
toContain
(
'./pages/index.tsx:2:31'
)
stderr
:
true
,
expect
(
stderr
).
toContain
(
"not assignable to type 'boolean'"
)
})
}
if
(
ignoreBuildErrors
)
{
expect
(
stdout
).
toContain
(
'Compiled successfully'
)
expect
(
stderr
).
not
.
toContain
(
'Failed to compile.'
)
expect
(
stderr
).
not
.
toContain
(
"not assignable to type 'boolean'"
)
}
else
{
expect
(
stdout
).
not
.
toContain
(
'Compiled successfully'
)
expect
(
stderr
).
toContain
(
'Failed to compile.'
)
expect
(
stderr
).
toContain
(
'./pages/index.tsx:2:31'
)
expect
(
stderr
).
toContain
(
"not assignable to type 'boolean'"
)
}
}
)
}
}
)
)
}
}
)
}
}
})
})
test/integration/worker-loader/test/index.test.js
View file @
e57b2091
...
@@ -9,7 +9,8 @@ const context = {}
...
@@ -9,7 +9,8 @@ const context = {}
jest
.
setTimeout
(
1000
*
60
*
2
)
jest
.
setTimeout
(
1000
*
60
*
2
)
describe
(
'Web Workers with Fast Refresh'
,
()
=>
{
// TODO: Upgrade worker-loader when it's published with webpack 5 support
describe
.
skip
(
'Web Workers with Fast Refresh'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
context
.
appPort
=
await
findPort
()
context
.
appPort
=
await
findPort
()
context
.
server
=
await
launchApp
(
appDir
,
context
.
appPort
)
context
.
server
=
await
launchApp
(
appDir
,
context
.
appPort
)
...
...
test/lib/next-test-utils.js
View file @
e57b2091
...
@@ -24,7 +24,7 @@ export function initNextServerScript(
...
@@ -24,7 +24,7 @@ export function initNextServerScript(
opts
opts
)
{
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
instance
=
spawn
(
'node'
,
[
scriptPath
],
{
env
})
const
instance
=
spawn
(
'node'
,
[
'--no-deprecation'
,
scriptPath
],
{
env
})
function
handleStdout
(
data
)
{
function
handleStdout
(
data
)
{
const
message
=
data
.
toString
()
const
message
=
data
.
toString
()
...
@@ -99,7 +99,7 @@ export function runNextCommand(argv, options = {}) {
...
@@ -99,7 +99,7 @@ export function runNextCommand(argv, options = {}) {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
`Running command "next
${
argv
.
join
(
' '
)}
"`
)
console
.
log
(
`Running command "next
${
argv
.
join
(
' '
)}
"`
)
const
instance
=
spawn
(
'node'
,
[
nextBin
,
...
argv
],
{
const
instance
=
spawn
(
'node'
,
[
'--no-deprecation'
,
nextBin
,
...
argv
],
{
...
options
.
spawnOptions
,
...
options
.
spawnOptions
,
cwd
,
cwd
,
env
,
env
,
...
@@ -159,7 +159,11 @@ export function runNextCommandDev(argv, stdOut, opts = {}) {
...
@@ -159,7 +159,11 @@ export function runNextCommandDev(argv, stdOut, opts = {}) {
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
instance
=
spawn
(
'node'
,
[
'dist/bin/next'
,
...
argv
],
{
cwd
,
env
})
const
instance
=
spawn
(
'node'
,
[
'--no-deprecation'
,
'dist/bin/next'
,
...
argv
],
{
cwd
,
env
}
)
let
didResolve
=
false
let
didResolve
=
false
function
handleStdout
(
data
)
{
function
handleStdout
(
data
)
{
...
@@ -246,7 +250,7 @@ export function buildTS(args = [], cwd, env = {}) {
...
@@ -246,7 +250,7 @@ export function buildTS(args = [], cwd, env = {}) {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
instance
=
spawn
(
const
instance
=
spawn
(
'node'
,
'node'
,
[
require
.
resolve
(
'typescript/lib/tsc'
),
...
args
],
[
'--no-deprecation'
,
require
.
resolve
(
'typescript/lib/tsc'
),
...
args
],
{
cwd
,
env
}
{
cwd
,
env
}
)
)
let
output
=
''
let
output
=
''
...
...
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