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
a46ce8a2
Commit
a46ce8a2
authored
Sep 08, 2025
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split up into ssr and rsc paths
parent
7a98924e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
167 additions
and
109 deletions
+167
-109
endpoint.rs
crates/napi/src/next_api/endpoint.rs
+10
-5
app.rs
crates/next-api/src/app.rs
+68
-46
instrumentation.rs
crates/next-api/src/instrumentation.rs
+2
-1
middleware.rs
crates/next-api/src/middleware.rs
+2
-1
pages.rs
crates/next-api/src/pages.rs
+7
-5
route.rs
crates/next-api/src/route.rs
+4
-2
client_reference_manifest.rs
...next-core/src/next_manifests/client_reference_manifest.rs
+5
-0
generated-native.d.ts
packages/next/src/build/swc/generated-native.d.ts
+2
-1
types.ts
packages/next/src/build/swc/types.ts
+10
-5
hot-reloader-turbopack.ts
packages/next/src/server/dev/hot-reloader-turbopack.ts
+57
-43
No files found.
crates/napi/src/next_api/endpoint.rs
View file @
a46ce8a2
...
@@ -46,7 +46,8 @@ pub struct NapiWrittenEndpoint {
...
@@ -46,7 +46,8 @@ pub struct NapiWrittenEndpoint {
pub
r
#
type
:
String
,
pub
r
#
type
:
String
,
pub
entry_path
:
Option
<
String
>
,
pub
entry_path
:
Option
<
String
>
,
pub
client_paths
:
Vec
<
String
>
,
pub
client_paths
:
Vec
<
String
>
,
pub
server_paths
:
Vec
<
NapiServerPath
>
,
pub
rsc_paths
:
Vec
<
NapiServerPath
>
,
pub
ssr_paths
:
Vec
<
NapiServerPath
>
,
pub
config
:
NapiEndpointConfig
,
pub
config
:
NapiEndpointConfig
,
}
}
...
@@ -55,22 +56,26 @@ impl From<Option<EndpointOutputPaths>> for NapiWrittenEndpoint {
...
@@ -55,22 +56,26 @@ impl From<Option<EndpointOutputPaths>> for NapiWrittenEndpoint {
match
written_endpoint
{
match
written_endpoint
{
Some
(
EndpointOutputPaths
::
NodeJs
{
Some
(
EndpointOutputPaths
::
NodeJs
{
server_entry_path
,
server_entry_path
,
server_paths
,
rsc_paths
,
ssr_paths
,
client_paths
,
client_paths
,
})
=>
Self
{
})
=>
Self
{
r
#
type
:
"nodejs"
.to_string
(),
r
#
type
:
"nodejs"
.to_string
(),
entry_path
:
Some
(
server_entry_path
.into_owned
()),
entry_path
:
Some
(
server_entry_path
.into_owned
()),
client_paths
:
client_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
client_paths
:
client_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
server_paths
:
server_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
rsc_paths
:
rsc_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
ssr_paths
:
ssr_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
..
Default
::
default
()
..
Default
::
default
()
},
},
Some
(
EndpointOutputPaths
::
Edge
{
Some
(
EndpointOutputPaths
::
Edge
{
server_paths
,
rsc_paths
,
ssr_paths
,
client_paths
,
client_paths
,
})
=>
Self
{
})
=>
Self
{
r
#
type
:
"edge"
.to_string
(),
r
#
type
:
"edge"
.to_string
(),
client_paths
:
client_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
client_paths
:
client_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
server_paths
:
server_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
rsc_paths
:
rsc_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
ssr_paths
:
ssr_paths
.into_iter
()
.map
(
From
::
from
)
.collect
(),
..
Default
::
default
()
..
Default
::
default
()
},
},
Some
(
EndpointOutputPaths
::
NotFound
)
|
None
=>
Self
{
Some
(
EndpointOutputPaths
::
NotFound
)
|
None
=>
Self
{
...
...
crates/next-api/src/app.rs
View file @
a46ce8a2
This diff is collapsed.
Click to expand it.
crates/next-api/src/instrumentation.rs
View file @
a46ce8a2
...
@@ -252,7 +252,8 @@ impl Endpoint for InstrumentationEndpoint {
...
@@ -252,7 +252,8 @@ impl Endpoint for InstrumentationEndpoint {
Ok
(
EndpointOutput
{
Ok
(
EndpointOutput
{
output_assets
:
output_assets
.to_resolved
()
.await
?
,
output_assets
:
output_assets
.to_resolved
()
.await
?
,
output_paths
:
EndpointOutputPaths
::
Edge
{
output_paths
:
EndpointOutputPaths
::
Edge
{
server_paths
,
rsc_paths
:
server_paths
,
ssr_paths
:
vec!
[],
client_paths
:
vec!
[],
client_paths
:
vec!
[],
}
}
.resolved_cell
(),
.resolved_cell
(),
...
...
crates/next-api/src/middleware.rs
View file @
a46ce8a2
...
@@ -381,7 +381,8 @@ impl Endpoint for MiddlewareEndpoint {
...
@@ -381,7 +381,8 @@ impl Endpoint for MiddlewareEndpoint {
Ok
(
EndpointOutput
{
Ok
(
EndpointOutput
{
output_paths
:
EndpointOutputPaths
::
Edge
{
output_paths
:
EndpointOutputPaths
::
Edge
{
server_paths
,
rsc_paths
:
server_paths
,
ssr_paths
:
vec!
[],
client_paths
,
client_paths
,
}
}
.resolved_cell
(),
.resolved_cell
(),
...
...
crates/next-api/src/pages.rs
View file @
a46ce8a2
...
@@ -1676,14 +1676,14 @@ impl Endpoint for PageEndpoint {
...
@@ -1676,14 +1676,14 @@ impl Endpoint for PageEndpoint {
let
node_root
=
this
.pages_project
.project
()
.node_root
()
.owned
()
.await
?
;
let
node_root
=
this
.pages_project
.project
()
.node_root
()
.owned
()
.await
?
;
let
(
s
erve
r_paths
,
client_paths
)
=
if
this
let
(
s
s
r_paths
,
client_paths
)
=
if
this
.pages_project
.pages_project
.project
()
.project
()
.next_mode
()
.next_mode
()
.await
?
.await
?
.is_development
()
.is_development
()
{
{
let
s
erve
r_paths
=
all_server_paths
(
output_assets
,
node_root
.clone
())
let
s
s
r_paths
=
all_server_paths
(
output_assets
,
node_root
.clone
())
.owned
()
.owned
()
.await
?
;
.await
?
;
...
@@ -1697,7 +1697,7 @@ impl Endpoint for PageEndpoint {
...
@@ -1697,7 +1697,7 @@ impl Endpoint for PageEndpoint {
.owned
()
.owned
()
.instrument
(
tracing
::
info_span!
(
"client_paths"
))
.instrument
(
tracing
::
info_span!
(
"client_paths"
))
.await
?
;
.await
?
;
(
s
erve
r_paths
,
client_paths
)
(
s
s
r_paths
,
client_paths
)
}
else
{
}
else
{
(
vec!
[],
vec!
[])
(
vec!
[],
vec!
[])
};
};
...
@@ -1718,12 +1718,14 @@ impl Endpoint for PageEndpoint {
...
@@ -1718,12 +1718,14 @@ impl Endpoint for PageEndpoint {
EndpointOutputPaths
::
NodeJs
{
EndpointOutputPaths
::
NodeJs
{
server_entry_path
,
server_entry_path
,
server_paths
,
rsc_paths
:
vec!
[],
ssr_paths
,
client_paths
,
client_paths
,
}
}
}
}
PageEndpointOutput
::
Edge
{
..
}
=>
EndpointOutputPaths
::
Edge
{
PageEndpointOutput
::
Edge
{
..
}
=>
EndpointOutputPaths
::
Edge
{
server_paths
,
rsc_paths
:
vec!
[],
ssr_paths
,
client_paths
,
client_paths
,
},
},
};
};
...
...
crates/next-api/src/route.rs
View file @
a46ce8a2
...
@@ -148,11 +148,13 @@ pub enum EndpointOutputPaths {
...
@@ -148,11 +148,13 @@ pub enum EndpointOutputPaths {
NodeJs
{
NodeJs
{
/// Relative to the root_path
/// Relative to the root_path
server_entry_path
:
RcStr
,
server_entry_path
:
RcStr
,
server_paths
:
Vec
<
ServerPath
>
,
ssr_paths
:
Vec
<
ServerPath
>
,
rsc_paths
:
Vec
<
ServerPath
>
,
client_paths
:
Vec
<
RcStr
>
,
client_paths
:
Vec
<
RcStr
>
,
},
},
Edge
{
Edge
{
server_paths
:
Vec
<
ServerPath
>
,
ssr_paths
:
Vec
<
ServerPath
>
,
rsc_paths
:
Vec
<
ServerPath
>
,
client_paths
:
Vec
<
RcStr
>
,
client_paths
:
Vec
<
RcStr
>
,
},
},
NotFound
,
NotFound
,
...
...
crates/next-core/src/next_manifests/client_reference_manifest.rs
View file @
a46ce8a2
...
@@ -292,6 +292,11 @@ impl ClientReferenceManifest {
...
@@ -292,6 +292,11 @@ impl ClientReferenceManifest {
ManifestNodeEntry
{
ManifestNodeEntry
{
name
:
rcstr!
(
"*"
),
name
:
rcstr!
(
"*"
),
id
:
(
&*
rsc_chunk_item_id
)
.into
(),
id
:
(
&*
rsc_chunk_item_id
)
.into
(),
// When a use-cache function runs, it's in the same Node.js context as
// the parent RSC page renderer, so all needed chunks are loaded already
// anyway. So if the use-cache function returns client references in the
// RSC payload that the page context needs, then these modules are
// already loaded.
chunks
:
vec!
[],
chunks
:
vec!
[],
r
#
async
:
rsc_is_async
,
r
#
async
:
rsc_is_async
,
},
},
...
...
packages/next/src/build/swc/generated-native.d.ts
View file @
a46ce8a2
...
@@ -61,7 +61,8 @@ export interface NapiWrittenEndpoint {
...
@@ -61,7 +61,8 @@ export interface NapiWrittenEndpoint {
type
:
string
type
:
string
entryPath
?:
string
entryPath
?:
string
clientPaths
:
Array
<
string
>
clientPaths
:
Array
<
string
>
serverPaths
:
Array
<
NapiServerPath
>
rscPaths
:
Array
<
NapiServerPath
>
ssrPaths
:
Array
<
NapiServerPath
>
config
:
NapiEndpointConfig
config
:
NapiEndpointConfig
}
}
export
declare
function
endpointWriteToDisk
(
endpoint
:
{
export
declare
function
endpointWriteToDisk
(
endpoint
:
{
...
...
packages/next/src/build/swc/types.ts
View file @
a46ce8a2
...
@@ -333,22 +333,27 @@ export type WrittenEndpoint =
...
@@ -333,22 +333,27 @@ export type WrittenEndpoint =
entryPath
:
string
entryPath
:
string
/** All client paths that have been written for the endpoint. */
/** All client paths that have been written for the endpoint. */
clientPaths
:
string
[]
clientPaths
:
string
[]
/** All server paths that have been written for the endpoint. */
/** All SSR server paths that have been written for the endpoint. */
serverPaths
:
ServerPath
[]
ssrPaths
:
ServerPath
[]
/** All RSC server paths that have been written for the endpoint. */
rscPaths
:
ServerPath
[]
config
:
EndpointConfig
config
:
EndpointConfig
}
}
|
{
|
{
type
:
'edge'
type
:
'edge'
/** All client paths that have been written for the endpoint. */
/** All client paths that have been written for the endpoint. */
clientPaths
:
string
[]
clientPaths
:
string
[]
/** All server paths that have been written for the endpoint. */
/** All SSR server paths that have been written for the endpoint. */
serverPaths
:
ServerPath
[]
ssrPaths
:
ServerPath
[]
/** All RSC server paths that have been written for the endpoint. */
rscPaths
:
ServerPath
[]
config
:
EndpointConfig
config
:
EndpointConfig
}
}
|
{
|
{
type
:
'none'
type
:
'none'
clientPaths
:
[]
clientPaths
:
[]
serverPaths
:
[]
ssrPaths
:
[]
rscPaths
:
[]
config
:
EndpointConfig
config
:
EndpointConfig
}
}
...
...
packages/next/src/server/dev/hot-reloader-turbopack.ts
View file @
a46ce8a2
...
@@ -23,6 +23,7 @@ import type {
...
@@ -23,6 +23,7 @@ import type {
TurbopackResult
,
TurbopackResult
,
Project
,
Project
,
Entrypoints
,
Entrypoints
,
ServerPath
,
}
from
'../../build/swc/types'
}
from
'../../build/swc/types'
import
{
createDefineEnv
}
from
'../../build/swc'
import
{
createDefineEnv
}
from
'../../build/swc'
import
*
as
Log
from
'../../build/output/log'
import
*
as
Log
from
'../../build/output/log'
...
@@ -312,64 +313,77 @@ export async function createHotReloaderTurbopack(
...
@@ -312,64 +313,77 @@ export async function createHotReloaderTurbopack(
force
?:
boolean
force
?:
boolean
}
=
{}
}
=
{}
):
boolean
{
):
boolean
{
if
(
force
)
{
function
shouldClear
(
paths
:
ServerPath
[]):
boolean
{
for
(
const
{
path
,
contentHash
}
of
writtenEndpoint
.
serverPaths
)
{
if
(
force
)
{
// We ignore source maps
for
(
const
{
path
,
contentHash
}
of
paths
)
{
if
(
path
.
endsWith
(
'.map'
))
continue
// We ignore source maps
const
localKey
=
`
${
key
}
:
${
path
}
`
if
(
path
.
endsWith
(
'.map'
))
continue
serverPathState
.
set
(
localKey
,
contentHash
)
const
localKey
=
`
${
key
}
:
${
path
}
`
serverPathState
.
set
(
path
,
contentHash
)
}
}
else
{
// Figure out if the server files have changed
let
hasChange
=
false
for
(
const
{
path
,
contentHash
}
of
writtenEndpoint
.
serverPaths
)
{
// We ignore source maps
if
(
path
.
endsWith
(
'.map'
))
continue
const
localKey
=
`
${
key
}
:
${
path
}
`
const
localHash
=
serverPathState
.
get
(
localKey
)
const
globalHash
=
serverPathState
.
get
(
path
)
if
(
(
localHash
&&
localHash
!==
contentHash
)
||
(
globalHash
&&
globalHash
!==
contentHash
)
)
{
hasChange
=
true
serverPathState
.
set
(
localKey
,
contentHash
)
serverPathState
.
set
(
localKey
,
contentHash
)
serverPathState
.
set
(
path
,
contentHash
)
serverPathState
.
set
(
path
,
contentHash
)
}
else
{
}
if
(
!
localHash
)
{
return
true
}
else
{
// Figure out if the server files have changed
let
hasChange
=
false
for
(
const
{
path
,
contentHash
}
of
paths
)
{
// We ignore source maps
if
(
path
.
endsWith
(
'.map'
))
continue
const
localKey
=
`
${
key
}
:
${
path
}
`
const
localHash
=
serverPathState
.
get
(
localKey
)
const
globalHash
=
serverPathState
.
get
(
path
)
if
(
(
localHash
&&
localHash
!==
contentHash
)
||
(
globalHash
&&
globalHash
!==
contentHash
)
)
{
hasChange
=
true
serverPathState
.
set
(
localKey
,
contentHash
)
serverPathState
.
set
(
localKey
,
contentHash
)
}
if
(
!
globalHash
)
{
serverPathState
.
set
(
path
,
contentHash
)
serverPathState
.
set
(
path
,
contentHash
)
}
else
{
if
(
!
localHash
)
{
serverPathState
.
set
(
localKey
,
contentHash
)
}
if
(
!
globalHash
)
{
serverPathState
.
set
(
path
,
contentHash
)
}
}
}
}
}
}
if
(
!
hasChange
)
{
return
hasChange
return
false
}
}
}
}
resetFetch
()
let
hasCleared
=
false
for
(
const
paths
of
[
writtenEndpoint
.
ssrPaths
,
writtenEndpoint
.
rscPaths
])
{
let
x
=
shouldClear
(
paths
)
console
.
log
(
key
,
x
,
paths
===
writtenEndpoint
.
ssrPaths
?
'ssr'
:
'rsc'
,
writtenEndpoint
)
if
(
x
)
{
hasCleared
=
true
// Not available in:
resetFetch
()
// - Pages Router (no server-side HMR)
// - Edge Runtime (uses browser runtime which already disposes chunks individually)
if
(
typeof
__next__clear_chunk_cache__
===
'function'
)
{
__next__clear_chunk_cache__
()
}
const
serverPaths
=
writtenEndpoint
.
serverPaths
.
map
(({
path
:
p
})
=>
// Not available in:
join
(
distDir
,
p
)
// - Pages Router (no server-side HMR)
)
// - Edge Runtime (uses browser runtime which already disposes chunks individually)
if
(
typeof
__next__clear_chunk_cache__
===
'function'
)
{
__next__clear_chunk_cache__
()
}
const
serverPaths
=
paths
.
map
(({
path
:
p
})
=>
join
(
distDir
,
p
))
for
(
const
file
of
serverPaths
)
{
for
(
const
file
of
serverPaths
)
{
clearModuleContext
(
file
)
clearModuleContext
(
file
)
deleteCache
(
file
)
deleteCache
(
file
)
}
}
}
}
return
true
return
hasCleared
}
}
const
buildingIds
=
new
Set
()
const
buildingIds
=
new
Set
()
...
...
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