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
acf1625d
Commit
acf1625d
authored
Feb 05, 2026
by
Will Binns-Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply suggestion from @sokra
Co-authored-by:
Tobias Koppers
<
tobias.koppers@googlemail.com
>
parent
fdbe45aa
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
69 deletions
+65
-69
project.rs
crates/next-api/src/project.rs
+8
-8
lib.rs
crates/next-build-test/src/lib.rs
+1
-1
project.rs
crates/next-napi-bindings/src/next_api/project.rs
+33
-33
generated-native.d.ts
packages/next/src/build/swc/generated-native.d.ts
+3
-3
index.ts
packages/next/src/build/swc/index.ts
+4
-4
types.ts
packages/next/src/build/swc/types.ts
+5
-5
hot-reloader-turbopack.ts
packages/next/src/server/dev/hot-reloader-turbopack.ts
+2
-4
next-rs-api.test.ts
test/development/basic/next-rs-api.test.ts
+9
-11
No files found.
crates/next-api/src/project.rs
View file @
acf1625d
...
...
@@ -739,10 +739,10 @@ impl ProjectContainer {
self
.project
()
.entrypoints
()
}
/// See [Project::client_hmr_
identifier
s].
/// See [Project::client_hmr_
chunk_name
s].
#[turbo_tasks
::
function]
pub
fn
client_hmr_
identifier
s
(
self
:
Vc
<
Self
>
)
->
Vc
<
Vec
<
RcStr
>>
{
self
.project
()
.client_hmr_
identifier
s
()
pub
fn
client_hmr_
chunk_name
s
(
self
:
Vc
<
Self
>
)
->
Vc
<
Vec
<
RcStr
>>
{
self
.project
()
.client_hmr_
chunk_name
s
()
}
/// Gets a source map for a particular `file_path`. If `dev` mode is disabled, this will always
...
...
@@ -2104,10 +2104,10 @@ impl Project {
}
}
/// Gets a list of all HMR
identifier
s that can be subscribed to. This is
/// Gets a list of all HMR
chunk name
s that can be subscribed to. This is
/// only needed for testing purposes and isn't used in real apps.
#[turbo_tasks
::
function]
pub
async
fn
client_hmr_
identifier
s
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
Vec
<
RcStr
>>>
{
pub
async
fn
client_hmr_
chunk_name
s
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
Vec
<
RcStr
>>>
{
if
let
Some
(
map
)
=
self
.await
?
.versioned_content_map
{
Ok
(
map
.keys_in_path
(
self
.client_relative_path
()
.owned
()
.await
?
))
}
else
{
...
...
@@ -2190,11 +2190,11 @@ impl Project {
}
}
/// Gets a list of all server HMR
identifier
s that can be subscribed to.
/// Gets a list of all server HMR
chunk name
s that can be subscribed to.
/// These are paths relative to node_root (e.g., "server/app/page.js").
/// This is the server-side equivalent of `hmr_
identifier
s`.
/// This is the server-side equivalent of `hmr_
chunk_name
s`.
#[turbo_tasks
::
function]
pub
async
fn
server_hmr_
identifier
s
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
Vec
<
RcStr
>>>
{
pub
async
fn
server_hmr_
chunk_name
s
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
Vec
<
RcStr
>>>
{
if
let
Some
(
map
)
=
self
.await
?
.versioned_content_map
{
Ok
(
map
.keys_in_path
(
self
.node_root
()
.owned
()
.await
?
))
}
else
{
...
...
crates/next-build-test/src/lib.rs
View file @
acf1625d
...
...
@@ -257,7 +257,7 @@ async fn hmr(
tracing
::
info!
(
"HMR..."
);
let
session
=
TransientInstance
::
new
(());
let
idents
=
tt
.run
(
async
move
{
project
.client_hmr_
identifier
s
()
.await
})
.run
(
async
move
{
project
.client_hmr_
chunk_name
s
()
.await
})
.await
?
;
let
start
=
Instant
::
now
();
for
ident
in
idents
{
...
...
crates/next-napi-bindings/src/next_api/project.rs
View file @
acf1625d
...
...
@@ -1195,14 +1195,14 @@ pub fn project_entrypoints_subscribe(
)
}
#[derive(Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
TaskInput,
Encode,
Decode,
TraceRawVcs)]
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
TaskInput,
Encode,
Decode,
TraceRawVcs,
NonLocalValue,
)]
enum
HmrTarget
{
Client
,
Server
,
}
unsafe
impl
turbo_tasks
::
NonLocalValue
for
HmrTarget
{}
impl
std
::
str
::
FromStr
for
HmrTarget
{
type
Err
=
String
;
...
...
@@ -1373,47 +1373,47 @@ pub fn project_hmr_events(
}
#[napi(object)]
struct
Hmr
Identifier
s
{
pub
chunk_
path
s
:
Vec
<
RcStr
>
,
struct
Hmr
ChunkName
s
{
pub
chunk_
name
s
:
Vec
<
RcStr
>
,
}
#[turbo_tasks
::
value(serialization
=
"none"
)]
struct
Hmr
Identifier
sWithIssues
{
chunk_
path
s
:
ReadRef
<
Vec
<
RcStr
>>
,
struct
Hmr
ChunkName
sWithIssues
{
chunk_
name
s
:
ReadRef
<
Vec
<
RcStr
>>
,
issues
:
Arc
<
Vec
<
ReadRef
<
PlainIssue
>>>
,
diagnostics
:
Arc
<
Vec
<
ReadRef
<
PlainDiagnostic
>>>
,
effects
:
Arc
<
Effects
>
,
}
#[turbo_tasks
::
function(operation)]
fn
project_container_client_hmr_
identifier
s_operation
(
fn
project_container_client_hmr_
chunk_name
s_operation
(
container
:
ResolvedVc
<
ProjectContainer
>
,
)
->
Vc
<
Vec
<
RcStr
>>
{
container
.client_hmr_
identifier
s
()
container
.client_hmr_
chunk_name
s
()
}
#[turbo_tasks
::
function(operation)]
fn
project_server_hmr_
identifier
s_operation
(
fn
project_server_hmr_
chunk_name
s_operation
(
container
:
ResolvedVc
<
ProjectContainer
>
,
)
->
Vc
<
Vec
<
RcStr
>>
{
container
.project
()
.server_hmr_
identifier
s
()
container
.project
()
.server_hmr_
chunk_name
s
()
}
#[turbo_tasks
::
function(operation)]
async
fn
get_hmr_
identifier
s_with_issues_operation
(
async
fn
get_hmr_
chunk_name
s_with_issues_operation
(
container
:
ResolvedVc
<
ProjectContainer
>
,
target
:
HmrTarget
,
)
->
Result
<
Vc
<
Hmr
Identifier
sWithIssues
>>
{
let
hmr_
identifier
s_op
=
match
target
{
HmrTarget
::
Client
=>
project_container_client_hmr_
identifier
s_operation
(
container
),
HmrTarget
::
Server
=>
project_server_hmr_
identifier
s_operation
(
container
),
)
->
Result
<
Vc
<
Hmr
ChunkName
sWithIssues
>>
{
let
hmr_
chunk_name
s_op
=
match
target
{
HmrTarget
::
Client
=>
project_container_client_hmr_
chunk_name
s_operation
(
container
),
HmrTarget
::
Server
=>
project_server_hmr_
chunk_name
s_operation
(
container
),
};
let
hmr_
identifiers
=
hmr_identifier
s_op
.read_strongly_consistent
()
.await
?
;
let
issues
=
get_issues
(
hmr_
identifier
s_op
,
NEXT_ISSUE_FILTER
)
.await
?
;
let
diagnostics
=
get_diagnostics
(
hmr_
identifier
s_op
)
.await
?
;
let
effects
=
Arc
::
new
(
get_effects
(
hmr_
identifier
s_op
)
.await
?
);
Ok
(
Hmr
Identifier
sWithIssues
{
chunk_
paths
:
hmr_identifier
s
,
let
hmr_
chunk_names
=
hmr_chunk_name
s_op
.read_strongly_consistent
()
.await
?
;
let
issues
=
get_issues
(
hmr_
chunk_name
s_op
,
NEXT_ISSUE_FILTER
)
.await
?
;
let
diagnostics
=
get_diagnostics
(
hmr_
chunk_name
s_op
)
.await
?
;
let
effects
=
Arc
::
new
(
get_effects
(
hmr_
chunk_name
s_op
)
.await
?
);
Ok
(
Hmr
ChunkName
sWithIssues
{
chunk_
names
:
hmr_chunk_name
s
,
issues
,
diagnostics
,
effects
,
...
...
@@ -1421,9 +1421,9 @@ async fn get_hmr_identifiers_with_issues_operation(
.cell
())
}
#[tracing
::
instrument(level
=
"info"
,
name
=
"get HMR
identifier
s"
,
skip(project,
func),
fields(target
=
%
target))]
#[tracing
::
instrument(level
=
"info"
,
name
=
"get HMR
chunk name
s"
,
skip(project,
func),
fields(target
=
%
target))]
#[napi(ts_return_type
=
"{ __napiType:
\
"
RootTask
\
" }"
)]
pub
fn
project_hmr_
identifier
s_subscribe
(
pub
fn
project_hmr_
chunk_name
s_subscribe
(
#[napi(ts_arg_type
=
"{ __napiType:
\
"
Project
\
" }"
)]
project
:
External
<
ProjectInstance
>
,
target
:
String
,
func
:
JsFunction
,
...
...
@@ -1437,26 +1437,26 @@ pub fn project_hmr_identifiers_subscribe(
project
.turbopack_ctx
.clone
(),
func
,
move
||
async
move
{
let
hmr_
identifier
s_with_issues_op
=
get_hmr_
identifier
s_with_issues_operation
(
container
,
hmr_target
);
let
Hmr
Identifier
sWithIssues
{
chunk_
path
s
,
let
hmr_
chunk_name
s_with_issues_op
=
get_hmr_
chunk_name
s_with_issues_operation
(
container
,
hmr_target
);
let
Hmr
ChunkName
sWithIssues
{
chunk_
name
s
,
issues
,
diagnostics
,
effects
,
}
=
&*
hmr_
identifier
s_with_issues_op
}
=
&*
hmr_
chunk_name
s_with_issues_op
.read_strongly_consistent
()
.await
?
;
effects
.apply
()
.await
?
;
Ok
((
chunk_
path
s
.clone
(),
issues
.clone
(),
diagnostics
.clone
()))
Ok
((
chunk_
name
s
.clone
(),
issues
.clone
(),
diagnostics
.clone
()))
},
move
|
ctx
|
{
let
(
chunk_
path
s
,
issues
,
diagnostics
)
=
ctx
.value
;
let
(
chunk_
name
s
,
issues
,
diagnostics
)
=
ctx
.value
;
Ok
(
vec!
[
TurbopackResult
{
result
:
Hmr
Identifier
s
{
chunk_
paths
:
ReadRef
::
into_owned
(
chunk_path
s
),
result
:
Hmr
ChunkName
s
{
chunk_
names
:
ReadRef
::
into_owned
(
chunk_name
s
),
},
issues
:
issues
.iter
()
...
...
packages/next/src/build/swc/generated-native.d.ts
View file @
acf1625d
...
...
@@ -319,10 +319,10 @@ export declare function projectHmrEvents(
target
:
string
,
func
:
(...
args
:
any
[])
=>
any
):
{
__napiType
:
'RootTask'
}
export
interface
Hmr
Identifier
s
{
chunk
Path
s
:
Array
<
RcStr
>
export
interface
Hmr
ChunkName
s
{
chunk
Name
s
:
Array
<
RcStr
>
}
export
declare
function
projectHmr
Identifier
sSubscribe
(
export
declare
function
projectHmr
ChunkName
sSubscribe
(
project
:
{
__napiType
:
'Project'
},
target
:
string
,
func
:
(...
args
:
any
[])
=>
any
...
...
packages/next/src/build/swc/index.ts
View file @
acf1625d
...
...
@@ -27,7 +27,7 @@ import type {
CompilationEvent
,
DefineEnv
,
Endpoint
,
Hmr
Identifier
s
,
Hmr
ChunkName
s
,
Lockfile
,
NodeJsHmrUpdate
,
PartialProjectOptions
,
...
...
@@ -765,11 +765,11 @@ function bindingToApi(
* Chunk paths are output file paths like "server/chunks/ssr/..._.js" for server
* or "_next/static/chunks/app/page.js" for client.
*/
hmr
Identifier
sSubscribe(target: HmrTarget) {
return subscribe<TurbopackResult<Hmr
Identifier
s>>(
hmr
ChunkName
sSubscribe(target: HmrTarget) {
return subscribe<TurbopackResult<Hmr
ChunkName
s>>(
false,
async (callback) =>
binding.projectHmr
Identifier
sSubscribe(
binding.projectHmr
ChunkName
sSubscribe(
this._nativeProject,
target,
callback
...
...
packages/next/src/build/swc/types.ts
View file @
acf1625d
...
...
@@ -216,9 +216,9 @@ export interface NodeJsPartialHmrUpdate extends BaseUpdate {
export
type
NodeJsHmrUpdate
=
IssuesUpdate
|
NodeJsPartialHmrUpdate
export
interface
Hmr
Identifier
s
{
/**
P
aths to output chunks that can receive HMR updates (e.g., "server/chunks/ssr/..._.js") */
chunk
Path
s
:
string
[]
export
interface
Hmr
ChunkName
s
{
/**
Relative p
aths to output chunks that can receive HMR updates (e.g., "server/chunks/ssr/..._.js") */
chunk
Name
s
:
string
[]
}
/** @see https://github.com/vercel/next.js/blob/415cd74b9a220b6f50da64da68c13043e9b02995/crates/next-napi-bindings/src/next_api/project.rs#L824-L833 */
...
...
@@ -277,9 +277,9 @@ export interface Project {
target
:
import
(
'./index'
).
HmrTarget
.
Server
):
AsyncIterableIterator
<
TurbopackResult
<
NodeJsHmrUpdate
>>
hmr
Identifier
sSubscribe
(
hmr
ChunkName
sSubscribe
(
target
:
import
(
'./index'
).
HmrTarget
):
AsyncIterableIterator
<
TurbopackResult
<
Hmr
Identifier
s
>>
):
AsyncIterableIterator
<
TurbopackResult
<
Hmr
ChunkName
s
>>
getSourceForAsset
(
filePath
:
string
):
Promise
<
string
|
null
>
...
...
packages/next/src/server/dev/hot-reloader-turbopack.ts
View file @
acf1625d
...
...
@@ -204,14 +204,12 @@ function setupServerHmr(project: Project) {
// Listen to the Rust bindings update us on changing server HMR chunk paths
;(
async
()
=>
{
const
serverHmrChunkPaths
=
project
.
hmrIdentifiersSubscribe
(
HmrTarget
.
Server
)
const
serverHmrChunkPaths
=
project
.
hmrChunkNamesSubscribe
(
HmrTarget
.
Server
)
// Process chunk paths (both initial and subsequent updates)
for
await
(
const
data
of
serverHmrChunkPaths
)
{
const
currentChunkPaths
=
new
Set
(
data
.
chunk
Path
s
.
filter
((
path
)
=>
path
.
endsWith
(
'.js'
))
data
.
chunk
Name
s
.
filter
((
path
)
=>
path
.
endsWith
(
'.js'
))
)
// Clean up subscriptions for removed chunk paths (like when pages are deleted)
...
...
test/development/basic/next-rs-api.test.ts
View file @
acf1625d
...
...
@@ -666,14 +666,14 @@ describe('next.rs api', () => {
}
const
result
=
await
project
.
hmr
Identifier
sSubscribe
(
HmrTarget
.
Client
)
.
hmr
ChunkName
sSubscribe
(
HmrTarget
.
Client
)
.
next
()
expect
(
result
.
done
).
toBe
(
false
)
const
chunk
Paths
=
result
.
value
.
chunk_path
s
expect
(
chunk
Path
s
).
toHaveProperty
(
'length'
,
expect
.
toBePositive
())
const
chunk
Names
=
result
.
value
.
chunkName
s
expect
(
chunk
Name
s
).
toHaveProperty
(
'length'
,
expect
.
toBePositive
())
const
subscriptions
=
chunk
Paths
.
map
((
chunkPath
)
=>
project
.
hmrEvents
(
chunk
Path
,
HmrTarget
.
Client
)
const
subscriptions
=
chunk
Names
.
map
((
chunkName
)
=>
project
.
hmrEvents
(
chunk
Name
,
HmrTarget
.
Client
)
)
await
Promise
.
all
(
subscriptions
.
map
(
async
(
subscription
)
=>
{
...
...
@@ -795,14 +795,12 @@ describe('next.rs api', () => {
if
(
route
.
type
!==
'page'
)
throw
new
Error
(
'unknown route type'
)
await
route
.
htmlEndpoint
.
writeToDisk
()
const
result
=
await
project
.
hmrIdentifiersSubscribe
(
HmrTarget
.
Client
)
.
next
()
const
result
=
await
project
.
hmrChunkNamesSubscribe
(
HmrTarget
.
Client
).
next
()
expect
(
result
.
done
).
toBe
(
false
)
const
identifiers
=
result
.
value
.
identifier
s
const
chunkNames
=
result
.
value
.
chunkName
s
const
subscriptions
=
identifiers
.
map
((
identifier
)
=>
project
.
hmrEvents
(
identifier
,
HmrTarget
.
Client
)
const
subscriptions
=
chunkNames
.
map
((
chunkName
)
=>
project
.
hmrEvents
(
chunkName
,
HmrTarget
.
Client
)
)
await
Promise
.
all
(
subscriptions
.
map
(
async
(
subscription
)
=>
{
...
...
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