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
775bdc34
Unverified
Commit
775bdc34
authored
Feb 24, 2021
by
Joe Haddad
Committed by
GitHub
Feb 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: correctly handle fallbacks for webpack 5 (#22497)
Co-authored-by:
JJ Kasper
<
jj@jjsweb.site
>
parent
9d2b0fc0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
50 deletions
+66
-50
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+1
-1
webpack-config.ts
packages/next/build/webpack-config.ts
+13
-9
index.test.js
test/integration/build-output/test/index.test.js
+0
-40
index.js
...tion/fallback-modules/fixtures/with-crypto/pages/index.js
+0
-0
index.test.js
test/integration/fallback-modules/test/index.test.js
+52
-0
No files found.
.github/workflows/build_test_deploy.yml
View file @
775bdc34
...
@@ -181,7 +181,7 @@ jobs:
...
@@ -181,7 +181,7 @@ jobs:
-
run
:
yarn install --check-files
-
run
:
yarn install --check-files
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
-
run
:
xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
-
run
:
xvfb-run node run-tests.js test/integration/{
fallback-modules,
link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
if
:
${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
testLegacyReact
:
testLegacyReact
:
...
...
packages/next/build/webpack-config.ts
View file @
775bdc34
...
@@ -389,15 +389,6 @@ export default async function getBaseWebpackConfig(
...
@@ -389,15 +389,6 @@ export default async function getBaseWebpackConfig(
],
],
alias
:
{
alias
:
{
next
:
NEXT_PROJECT_ROOT
,
next
:
NEXT_PROJECT_ROOT
,
...(
isWebpack5
&&
!
isServer
?
{
stream
:
require
.
resolve
(
'stream-browserify'
),
path
:
require
.
resolve
(
'path-browserify'
),
crypto
:
require
.
resolve
(
'crypto-browserify'
),
buffer
:
require
.
resolve
(
'buffer'
),
vm
:
require
.
resolve
(
'vm-browserify'
),
}
:
undefined
),
[
PAGES_DIR_ALIAS
]:
pagesDir
,
[
PAGES_DIR_ALIAS
]:
pagesDir
,
[
DOT_NEXT_ALIAS
]:
distDir
,
[
DOT_NEXT_ALIAS
]:
distDir
,
...
getOptimizedAliases
(
isServer
),
...
getOptimizedAliases
(
isServer
),
...
@@ -406,6 +397,19 @@ export default async function getBaseWebpackConfig(
...
@@ -406,6 +397,19 @@ export default async function getBaseWebpackConfig(
?
clientResolveRewrites
?
clientResolveRewrites
:
clientResolveRewritesNoop
,
:
clientResolveRewritesNoop
,
},
},
...(
isWebpack5
&&
!
isServer
?
{
// Full list of old polyfills is accessible here:
// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42
fallback
:
{
buffer
:
require
.
resolve
(
'buffer'
),
crypto
:
require
.
resolve
(
'crypto-browserify'
),
path
:
require
.
resolve
(
'path-browserify'
),
stream
:
require
.
resolve
(
'stream-browserify'
),
vm
:
require
.
resolve
(
'vm-browserify'
),
},
}
:
undefined
),
mainFields
:
isServer
?
[
'main'
,
'module'
]
:
[
'browser'
,
'module'
,
'main'
],
mainFields
:
isServer
?
[
'main'
,
'module'
]
:
[
'browser'
,
'module'
,
'main'
],
plugins
:
isWebpack5
plugins
:
isWebpack5
?
// webpack 5+ has the PnP resolver built-in by default:
?
// webpack 5+ has the PnP resolver built-in by default:
...
...
test/integration/build-output/test/index.test.js
View file @
775bdc34
...
@@ -134,46 +134,6 @@ describe('Build Output', () => {
...
@@ -134,46 +134,6 @@ describe('Build Output', () => {
})
})
})
})
describe
(
'Crypto Application'
,
()
=>
{
let
stdout
const
appDir
=
join
(
fixturesDir
,
'with-crypto'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
})
it
(
'should not include crypto'
,
async
()
=>
{
;({
stdout
}
=
await
nextBuild
(
appDir
,
[],
{
stdout
:
true
,
}))
console
.
log
(
stdout
)
const
parsePageSize
=
(
page
)
=>
stdout
.
match
(
new
RegExp
(
`
${
page
}
.*?((?:\\d|\\.){1,} (?:\\w{1,})) `
)
)[
1
]
const
parsePageFirstLoad
=
(
page
)
=>
stdout
.
match
(
new
RegExp
(
`
${
page
}
.*?(?:(?:\\d|\\.){1,}) .*? ((?:\\d|\\.){1,} (?:\\w{1,}))`
)
)[
1
]
const
indexSize
=
parsePageSize
(
'/'
)
const
indexFirstLoad
=
parsePageFirstLoad
(
'/'
)
expect
(
parseFloat
(
indexSize
)).
toBeLessThanOrEqual
(
3.1
)
expect
(
parseFloat
(
indexSize
)).
toBeGreaterThanOrEqual
(
2
)
expect
(
indexSize
.
endsWith
(
'kB'
)).
toBe
(
true
)
expect
(
parseFloat
(
indexFirstLoad
)).
toBeLessThanOrEqual
(
66.9
)
expect
(
parseFloat
(
indexFirstLoad
)).
toBeGreaterThanOrEqual
(
60
)
expect
(
indexFirstLoad
.
endsWith
(
'kB'
)).
toBe
(
true
)
})
})
describe
(
'Custom App Output'
,
()
=>
{
describe
(
'Custom App Output'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'with-app'
)
const
appDir
=
join
(
fixturesDir
,
'with-app'
)
...
...
test/integration/
build-output
/fixtures/with-crypto/pages/index.js
→
test/integration/
fallback-modules
/fixtures/with-crypto/pages/index.js
View file @
775bdc34
File moved
test/integration/fallback-modules/test/index.test.js
0 → 100644
View file @
775bdc34
/* eslint-env jest */
import
'flat-map-polyfill'
import
{
remove
}
from
'fs-extra'
import
{
nextBuild
}
from
'next-test-utils'
import
{
join
}
from
'path'
jest
.
setTimeout
(
1000
*
60
*
2
)
const
fixturesDir
=
join
(
__dirname
,
'..'
,
'fixtures'
)
describe
(
'Build Output'
,
()
=>
{
describe
(
'Crypto Application'
,
()
=>
{
let
stdout
const
appDir
=
join
(
fixturesDir
,
'with-crypto'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
})
it
(
'should not include crypto'
,
async
()
=>
{
;({
stdout
}
=
await
nextBuild
(
appDir
,
[],
{
stdout
:
true
,
}))
console
.
log
(
stdout
)
const
parsePageSize
=
(
page
)
=>
stdout
.
match
(
new
RegExp
(
`
${
page
}
.*?((?:\\d|\\.){1,} (?:\\w{1,})) `
)
)[
1
]
const
parsePageFirstLoad
=
(
page
)
=>
stdout
.
match
(
new
RegExp
(
`
${
page
}
.*?(?:(?:\\d|\\.){1,}) .*? ((?:\\d|\\.){1,} (?:\\w{1,}))`
)
)[
1
]
const
indexSize
=
parsePageSize
(
'/'
)
const
indexFirstLoad
=
parsePageFirstLoad
(
'/'
)
expect
(
parseFloat
(
indexSize
)).
toBeLessThanOrEqual
(
3.1
)
expect
(
parseFloat
(
indexSize
)).
toBeGreaterThanOrEqual
(
2
)
expect
(
indexSize
.
endsWith
(
'kB'
)).
toBe
(
true
)
expect
(
parseFloat
(
indexFirstLoad
)).
toBeLessThanOrEqual
(
67.5
)
expect
(
parseFloat
(
indexFirstLoad
)).
toBeGreaterThanOrEqual
(
60
)
expect
(
indexFirstLoad
.
endsWith
(
'kB'
)).
toBe
(
true
)
})
})
})
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