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
c9564849
Unverified
Commit
c9564849
authored
Jan 09, 2023
by
Tim Neutkens
Committed by
GitHub
Jan 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start client compiler when server components are finished compiling (#44716)
parent
9c6d5612
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
24 deletions
+38
-24
flight-client-entry-plugin.ts
...t/src/build/webpack/plugins/flight-client-entry-plugin.ts
+38
-24
No files found.
packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts
View file @
c9564849
...
@@ -121,7 +121,7 @@ export class FlightClientEntryPlugin {
...
@@ -121,7 +121,7 @@ export class FlightClientEntryPlugin {
}
}
async
createClientEntries
(
compiler
:
any
,
compilation
:
any
)
{
async
createClientEntries
(
compiler
:
any
,
compilation
:
any
)
{
const
promises
:
Array
<
const
addClientEntryAndSSRModulesList
:
Array
<
ReturnType
<
typeof
this
.
injectClientEntryAndSSRModules
>
ReturnType
<
typeof
this
.
injectClientEntryAndSSRModules
>
>
=
[]
>
=
[]
...
@@ -210,7 +210,7 @@ export class FlightClientEntryPlugin {
...
@@ -210,7 +210,7 @@ export class FlightClientEntryPlugin {
relativeRequest
.
replace
(
/
\.(
js|ts
)
x
?
$/
,
''
).
replace
(
/^src
[\\/]
/
,
''
)
relativeRequest
.
replace
(
/
\.(
js|ts
)
x
?
$/
,
''
).
replace
(
/^src
[\\/]
/
,
''
)
)
)
promises
.
push
(
addClientEntryAndSSRModulesList
.
push
(
this
.
injectClientEntryAndSSRModules
({
this
.
injectClientEntryAndSSRModules
({
compiler
,
compiler
,
compilation
,
compilation
,
...
@@ -222,7 +222,7 @@ export class FlightClientEntryPlugin {
...
@@ -222,7 +222,7 @@ export class FlightClientEntryPlugin {
}
}
// Create internal app
// Create internal app
promises
.
push
(
addClientEntryAndSSRModulesList
.
push
(
this
.
injectClientEntryAndSSRModules
({
this
.
injectClientEntryAndSSRModules
({
compiler
,
compiler
,
compilation
,
compilation
,
...
@@ -366,14 +366,25 @@ export class FlightClientEntryPlugin {
...
@@ -366,14 +366,25 @@ export class FlightClientEntryPlugin {
}
}
)
)
const
res
=
await
Promise
.
all
(
promises
)
// Invalidate in development to trigger recompilation
// Invalidate in development to trigger recompilation
const
invalidator
=
getInvalidator
()
const
invalidator
=
getInvalidator
()
// Check if any of the entry injections need an invalidation
// Check if any of the entry injections need an invalidation
if
(
invalidator
&&
res
.
includes
(
true
))
{
if
(
invalidator
&&
addClientEntryAndSSRModulesList
.
some
(
([
shouldInvalidate
])
=>
shouldInvalidate
===
true
)
)
{
invalidator
.
invalidate
([
COMPILER_NAMES
.
client
])
invalidator
.
invalidate
([
COMPILER_NAMES
.
client
])
}
}
// Client compiler is invalidated before awaiting the compilation of the SSR client component entries
// so that the client compiler is running in parallel to the server compiler.
await
Promise
.
all
(
addClientEntryAndSSRModulesList
.
map
(
(
addClientEntryAndSSRModules
)
=>
addClientEntryAndSSRModules
[
1
]
)
)
}
}
collectClientComponentsAndCSSForDependency
({
collectClientComponentsAndCSSForDependency
({
...
@@ -475,7 +486,7 @@ export class FlightClientEntryPlugin {
...
@@ -475,7 +486,7 @@ export class FlightClientEntryPlugin {
return
[
clientComponentImports
,
serverCSSImports
]
return
[
clientComponentImports
,
serverCSSImports
]
}
}
async
injectClientEntryAndSSRModules
({
injectClientEntryAndSSRModules
({
compiler
,
compiler
,
compilation
,
compilation
,
entryName
,
entryName
,
...
@@ -487,7 +498,7 @@ export class FlightClientEntryPlugin {
...
@@ -487,7 +498,7 @@ export class FlightClientEntryPlugin {
entryName
:
string
entryName
:
string
clientComponentImports
:
ClientComponentImports
clientComponentImports
:
ClientComponentImports
bundlePath
:
string
bundlePath
:
string
}):
Promise
<
boolean
>
{
}):
[
shouldInvalidate
:
boolean
,
addEntryPromise
:
Promise
<
void
>
]
{
let
shouldInvalidate
=
false
let
shouldInvalidate
=
false
const
loaderOptions
:
NextFlightClientEntryLoaderOptions
=
{
const
loaderOptions
:
NextFlightClientEntryLoaderOptions
=
{
...
@@ -549,22 +560,25 @@ export class FlightClientEntryPlugin {
...
@@ -549,22 +560,25 @@ export class FlightClientEntryPlugin {
}
}
)
)
// Add the dependency to the server compiler.
return
[
await
this
.
addEntry
(
shouldInvalidate
,
compilation
,
// Add the dependency to the server compiler.
// Reuse compilation context.
// This promise is awaited later using `Promise.all` in order to parallelize adding the entries.
compiler
.
context
,
// It ensures we can parallelize the SSR and Client compiler entries.
clientComponentEntryDep
,
this
.
addEntry
(
{
compilation
,
// By using the same entry name
// Reuse compilation context.
name
:
entryName
,
compiler
.
context
,
// Layer should be client for the SSR modules
clientComponentEntryDep
,
// This ensures the client components are bundled on client layer
{
layer
:
WEBPACK_LAYERS
.
client
,
// By using the same entry name
}
name
:
entryName
,
)
// Layer should be client for the SSR modules
// This ensures the client components are bundled on client layer
return
shouldInvalidate
layer
:
WEBPACK_LAYERS
.
client
,
}
),
]
}
}
addEntry
(
addEntry
(
...
...
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