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
9c8d0465
Unverified
Commit
9c8d0465
authored
Jan 01, 2021
by
JJ Kasper
Committed by
GitHub
Jan 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure all entries are cleared from cache on runtime change (#20652)
parent
16d464ca
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
26 deletions
+86
-26
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+1
-1
nextjs-require-cache-hot-reloader.ts
...uild/webpack/plugins/nextjs-require-cache-hot-reloader.ts
+18
-10
context.js
test/integration/ssr-ctx/context.js
+5
-0
_app.js
test/integration/ssr-ctx/pages/_app.js
+9
-0
index.js
test/integration/ssr-ctx/pages/index.js
+8
-7
index.test.js
test/integration/ssr-ctx/test/index.test.js
+45
-8
No files found.
.github/workflows/build_test_deploy.yml
View file @
9c8d0465
...
@@ -153,7 +153,7 @@ jobs:
...
@@ -153,7 +153,7 @@ jobs:
-
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
-
run
:
yarn list webpack react react-dom
-
run
:
yarn list webpack react react-dom
-
run
:
xvfb-run node run-tests.js test/integration/
link-ref/test/index.test.js test/integration/production/test/index.test.js test/integration/basic/test/index.test.js test/integration/async-modules/test/index.test.js test/integration/font-optimization
/test/index.test.js test/acceptance/*.test.js
-
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
testFirefox
:
testFirefox
:
name
:
Test Firefox (production)
name
:
Test Firefox (production)
...
...
packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts
View file @
9c8d0465
...
@@ -38,20 +38,28 @@ export class NextJsRequireCacheHotReloader implements Plugin {
...
@@ -38,20 +38,28 @@ export class NextJsRequireCacheHotReloader implements Plugin {
compilation
.
outputOptions
.
path
,
compilation
.
outputOptions
.
path
,
'webpack-runtime.js'
'webpack-runtime.js'
)
)
deleteCache
(
runtimeChunkPath
)
deleteCache
(
runtimeChunkPath
)
for
(
const
outputPath
of
this
.
previousOutputPathsWebpack5
)
{
// we need to make sure to clear all server entries from cache
if
(
!
this
.
currentOutputPathsWebpack5
.
has
(
outputPath
))
{
// since they can have a stale webpack-runtime cache
deleteCache
(
outputPath
)
// which needs to always be in-sync
}
const
entries
=
[...
compilation
.
entries
.
keys
()].
filter
((
entry
)
=>
}
entry
.
toString
().
startsWith
(
'pages/'
)
this
.
previousOutputPathsWebpack5
=
new
Set
(
this
.
currentOutputPathsWebpack5
)
)
this
.
currentOutputPathsWebpack5
.
clear
()
entries
.
forEach
((
page
)
=>
{
const
outputPath
=
path
.
join
(
compilation
.
outputOptions
.
path
,
page
+
'.js'
)
deleteCache
(
outputPath
)
})
})
})
this
.
previousOutputPathsWebpack5
=
new
Set
(
this
.
currentOutputPathsWebpack5
)
this
.
currentOutputPathsWebpack5
.
clear
()
return
return
}
}
...
...
test/integration/ssr-ctx/context.js
0 → 100644
View file @
9c8d0465
import
React
from
'react'
export
const
Idk
=
React
.
createContext
(
null
)
export
const
useIdk
=
()
=>
React
.
useContext
(
Idk
)
test/integration/ssr-ctx/pages/_app.js
0 → 100644
View file @
9c8d0465
import
{
Idk
}
from
'../context'
export
default
function
MyApp
({
Component
,
pageProps
})
{
return
(
<
Idk
.
Provider
value
=
"hello world"
>
<
Component
{...
pageProps
}
/
>
<
/Idk.Provider
>
)
}
test/integration/ssr-ctx/pages/index.js
View file @
9c8d0465
import
React
from
'react'
import
React
from
'react'
import
{
useIdk
}
from
'../context'
const
Idk
=
React
.
createContext
(
null
)
const
Page
=
()
=>
{
const
Page
=
()
=>
{
const
idk
=
useIdk
()
console
.
log
(
idk
)
return
(
return
(
<
div
>
<>
<
Idk
.
Provider
value
=
"hello world"
>
<
p
>
Value
:
{
idk
}
<
/p
>
<
Idk
.
Consumer
>
{(
idk
)
=>
<
p
>
Value
:
{
idk
}
<
/p>}</
Idk
.
Consumer
>
<
/
>
<
/Idk.Provider
>
<
/div
>
)
)
}
}
...
...
test/integration/ssr-ctx/test/index.test.js
View file @
9c8d0465
...
@@ -2,29 +2,66 @@
...
@@ -2,29 +2,66 @@
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
import
{
File
,
killApp
,
killApp
,
findPort
,
findPort
,
nextStart
,
nextStart
,
nextBuild
,
nextBuild
,
renderViaHTTP
,
renderViaHTTP
,
check
,
launchApp
,
}
from
'next-test-utils'
}
from
'next-test-utils'
jest
.
setTimeout
(
1000
*
30
)
jest
.
setTimeout
(
1000
*
30
)
const
appDir
=
join
(
__dirname
,
'../'
)
const
appDir
=
join
(
__dirname
,
'../'
)
const
appPg
=
new
File
(
join
(
appDir
,
'pages/_app.js'
))
let
appPort
let
appPort
let
app
let
app
describe
(
'Production Usage'
,
()
=>
{
const
runTests
=
(
isDev
)
=>
{
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
afterAll
(()
=>
killApp
(
app
))
it
(
'should render a page with context'
,
async
()
=>
{
it
(
'should render a page with context'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/'
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/'
)
expect
(
html
).
toMatch
(
/Value: .*
?
hello world/
)
expect
(
html
).
toMatch
(
/Value: .*
?
hello world/
)
})
})
if
(
isDev
)
{
it
(
'should render with context after change'
,
async
()
=>
{
appPg
.
replace
(
'hello world'
,
'new value'
)
try
{
await
check
(()
=>
renderViaHTTP
(
appPort
,
'/'
),
/Value: .*
?
new value/
)
}
finally
{
appPg
.
restore
()
}
await
check
(()
=>
renderViaHTTP
(
appPort
,
'/'
),
/Value: .*
?
hello world/
)
})
}
}
describe
(
'React Context'
,
()
=>
{
describe
(
'dev mode'
,
()
=>
{
beforeAll
(
async
()
=>
{
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
)
})
afterAll
(
async
()
=>
{
await
killApp
(
app
)
appPg
.
restore
()
})
runTests
(
true
)
})
describe
(
'production mode'
,
()
=>
{
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
afterAll
(()
=>
killApp
(
app
))
runTests
()
})
})
})
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