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
5f311cdd
Unverified
Commit
5f311cdd
authored
Dec 28, 2020
by
Joe Haddad
Committed by
GitHub
Dec 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Fast Refresh tests with webpack@5 (#20543)
parent
f02bf210
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
36 deletions
+47
-36
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+1
-1
webpack-config.ts
packages/next/build/webpack-config.ts
+1
-0
font-stylesheet-gathering-plugin.ts
...build/webpack/plugins/font-stylesheet-gathering-plugin.ts
+45
-35
No files found.
.github/workflows/build_test_deploy.yml
View file @
5f311cdd
...
@@ -148,7 +148,7 @@ jobs:
...
@@ -148,7 +148,7 @@ jobs:
steps
:
steps
:
-
uses
:
actions/checkout@v2
-
uses
:
actions/checkout@v2
-
run
:
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
-
run
:
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
-
run
:
cat package.json | jq '.resolutions.webpack = "^5.
0.0-beta.30
"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
cat package.json | jq '.resolutions.webpack = "^5.
11.1
"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
cat package.json | jq '.resolutions."react-dom" = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
cat package.json | jq '.resolutions."react-dom" = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
-
run
:
yarn install --check-files
-
run
:
yarn install --check-files
...
...
packages/next/build/webpack-config.ts
View file @
5f311cdd
...
@@ -1131,6 +1131,7 @@ export default async function getBaseWebpackConfig(
...
@@ -1131,6 +1131,7 @@ export default async function getBaseWebpackConfig(
if
(
!
webpackConfig
.
optimization
)
{
if
(
!
webpackConfig
.
optimization
)
{
webpackConfig
.
optimization
=
{}
webpackConfig
.
optimization
=
{}
}
}
webpackConfig
.
optimization
.
providedExports
=
false
webpackConfig
.
optimization
.
usedExports
=
false
webpackConfig
.
optimization
.
usedExports
=
false
}
}
...
...
packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts
View file @
5f311cdd
...
@@ -71,12 +71,12 @@ export class FontStylesheetGatheringPlugin {
...
@@ -71,12 +71,12 @@ export class FontStylesheetGatheringPlugin {
return
return
}
}
let
result
let
result
if
(
node
.
name
===
'__jsx'
)
{
if
(
node
.
name
===
'_
jsx'
||
node
.
name
===
'_
_jsx'
)
{
result
=
new
BasicEvaluatedExpression
()
result
=
new
BasicEvaluatedExpression
()
// @ts-ignore
// @ts-ignore
result
.
setRange
(
node
.
range
)
result
.
setRange
(
node
.
range
)
result
.
setExpression
(
node
)
result
.
setExpression
(
node
)
result
.
setIdentifier
(
'__jsx'
)
result
.
setIdentifier
(
node
.
name
)
// This was added webpack 5.
// This was added webpack 5.
if
(
isWebpack5
)
{
if
(
isWebpack5
)
{
...
@@ -86,9 +86,7 @@ export class FontStylesheetGatheringPlugin {
...
@@ -86,9 +86,7 @@ export class FontStylesheetGatheringPlugin {
return
result
return
result
})
})
parser
.
hooks
.
call
const
jsxNodeHandler
=
(
node
:
namedTypes
.
CallExpression
)
=>
{
.
for
(
'__jsx'
)
.
tap
(
this
.
constructor
.
name
,
(
node
:
namedTypes
.
CallExpression
)
=>
{
if
(
node
.
arguments
.
length
!==
2
)
{
if
(
node
.
arguments
.
length
!==
2
)
{
// A font link tag has only two arguments rel=stylesheet and href='...'
// A font link tag has only two arguments rel=stylesheet and href='...'
return
return
...
@@ -123,7 +121,15 @@ export class FontStylesheetGatheringPlugin {
...
@@ -123,7 +121,15 @@ export class FontStylesheetGatheringPlugin {
}
}
this
.
gatheredStylesheets
.
push
(
props
.
href
)
this
.
gatheredStylesheets
.
push
(
props
.
href
)
})
}
// React JSX transform:
parser
.
hooks
.
call
.
for
(
'_jsx'
)
.
tap
(
this
.
constructor
.
name
,
jsxNodeHandler
)
// Next.js JSX transform:
parser
.
hooks
.
call
.
for
(
'__jsx'
)
.
tap
(
this
.
constructor
.
name
,
jsxNodeHandler
)
})
})
}
}
}
}
...
@@ -213,6 +219,10 @@ function isNodeCreatingLinkElement(node: namedTypes.CallExpression) {
...
@@ -213,6 +219,10 @@ function isNodeCreatingLinkElement(node: namedTypes.CallExpression) {
if
(
componentNode
.
type
!==
'Literal'
)
{
if
(
componentNode
.
type
!==
'Literal'
)
{
return
false
return
false
}
}
// React has pragma: _jsx.
// Next has pragma: __jsx.
// Next has pragma: __jsx.
return
callee
.
name
===
'__jsx'
&&
componentNode
.
value
===
'link'
return
(
(
callee
.
name
===
'_jsx'
||
callee
.
name
===
'__jsx'
)
&&
componentNode
.
value
===
'link'
)
}
}
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