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
7e050637
Commit
7e050637
authored
Feb 05, 2026
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fileHashes to NFT file
parent
30b04a27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
325 additions
and
194 deletions
+325
-194
next_server_nft.rs
crates/next-api/src/next_server_nft.rs
+25
-13
nft_json.rs
crates/next-api/src/nft_json.rs
+19
-7
build-complete.ts
packages/next/src/build/adapter/build-complete.ts
+281
-174
No files found.
crates/next-api/src/next_server_nft.rs
View file @
7e050637
...
...
@@ -5,14 +5,15 @@ use bincode::{Decode, Encode};
use
either
::
Either
;
use
next_core
::{
get_next_package
,
next_server
::
get_tracing_compile_time_info
};
use
serde_json
::{
Value
,
json
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
{
RcStr
,
rcstr
}
;
use
turbo_tasks
::{
NonLocalValue
,
ResolvedVc
,
TaskInput
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Vc
,
NonLocalValue
,
Re
adRef
,
Re
solvedVc
,
TaskInput
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Vc
,
trace
::
TraceRawVcs
,
};
use
turbo_tasks_fs
::{
DirectoryContent
,
DirectoryEntry
,
File
,
FileContent
,
FileSystemPath
,
glob
::
Glob
,
};
use
turbo_tasks_hash
::
HashAlgorithm
;
use
turbopack
::
externals_tracing_module_context
;
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
...
...
@@ -111,25 +112,33 @@ impl Asset for ServerNftJsonAsset {
.await
?
.iter
()
.map
(
async
|
m
|
{
base_dir
.get_relative_path_to
(
&*
m
.path
()
.await
?
)
.context
(
"failed to compute relative path for server NFT JSON"
)
Ok
((
base_dir
.get_relative_path_to
(
&*
m
.path
()
.await
?
)
.context
(
"failed to compute relative path for server NFT JSON"
)
?
,
m
.content
()
.hash
(
HashAlgorithm
::
Xxh3Hash128Hex
)
.await
?
,
))
})
.try_join
()
.await
?
;
// A few hardcoded files (not recursive)
server_output_assets
.push
(
"./package.json"
.into
());
// TODO hash
server_output_assets
.push
((
"./package.json"
.into
(),
ReadRef
::
new_owned
(
rcstr!
(
"0"
))));
let
next_dir
=
get_next_package
(
this
.project
.project_path
()
.owned
()
.await
?
)
.await
?
;
for
ty
in
[
"app-page"
,
"pages"
]
{
let
dir
=
next_dir
.join
(
&
format!
(
"dist/server/route-modules/{ty}"
))
?
;
let
module_path
=
dir
.join
(
"module.compiled.js"
)
?
;
server_output_assets
.push
(
server_output_assets
.push
(
(
base_dir
.get_relative_path_to
(
&
module_path
)
.context
(
"failed to compute relative path for server NFT JSON"
)
?
,
);
module_path
.read
()
.hash
(
HashAlgorithm
::
Xxh3Hash128Hex
)
.await
?
,
));
let
contexts_dir
=
dir
.join
(
"vendored/contexts"
)
?
;
let
DirectoryContent
::
Entries
(
contexts_files
)
=
&*
contexts_dir
.read_dir
()
.await
?
else
{
...
...
@@ -143,24 +152,27 @@ impl Asset for ServerNftJsonAsset {
continue
;
};
if
file
.extension
()
==
Some
(
"js"
)
{
server_output_assets
.push
(
server_output_assets
.push
(
(
base_dir
.get_relative_path_to
(
file
)
.context
(
"failed to compute relative path for server NFT JSON"
)
?
,
)
file
.read
()
.hash
(
HashAlgorithm
::
Xxh3Hash128Hex
)
.await
?
,
))
}
}
}
server_output_assets
.sort
();
server_output_assets
.sort
_unstable
();
// Dedupe as some entries may be duplicates: a file might be referenced multiple times,
// e.g. as a RawModule (from an FS operation) and as an EcmascriptModuleAsset because it
// was required.
server_output_assets
.dedup
();
let
(
files
,
file_hashes
):
(
Vec
<
_
>
,
Vec
<
_
>
)
=
server_output_assets
.into_iter
()
.unzip
();
let
json
=
json!
({
"version"
:
1
,
"files"
:
server_output_assets
"version"
:
1
,
"files"
:
files
,
"fileHashes"
:
file_hashes
});
Ok
(
AssetContent
::
file
(
...
...
crates/next-api/src/nft_json.rs
View file @
7e050637
use
std
::
collections
::{
BTreeSet
,
HashSet
,
VecDeque
};
use
std
::
collections
::{
BTree
Map
,
BTree
Set
,
HashSet
,
VecDeque
};
use
anyhow
::{
Result
,
bail
};
use
async_trait
::
async_trait
;
...
...
@@ -14,6 +14,7 @@ use turbo_tasks_fs::{
DirectoryEntry
,
File
,
FileContent
,
FileSystem
,
FileSystemPath
,
glob
::{
Glob
,
GlobOptions
},
};
use
turbo_tasks_hash
::
HashAlgorithm
;
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
issue
::{
Issue
,
IssueExt
,
IssueSeverity
,
IssueStage
,
StyledString
},
...
...
@@ -106,14 +107,14 @@ async fn apply_includes(
project_root_path
:
FileSystemPath
,
glob
:
Vc
<
Glob
>
,
ident_folder
:
&
FileSystemPath
,
)
->
Result
<
BTree
Set
<
RcStr
>>
{
)
->
Result
<
BTree
Map
<
RcStr
,
ReadRef
<
RcStr
>
>>
{
debug_assert_eq!
(
project_root_path
.fs
,
ident_folder
.fs
);
// Read files matching the glob pattern from the project root
// This result itself has random order, but the BTreeSet will ensure a deterministic ordering.
let
glob_result
=
project_root_path
.read_glob
(
glob
)
.await
?
;
// Walk the full glob_result using an explicit stack to avoid async recursion overheads.
let
mut
result
=
BTree
Set
::
new
();
let
mut
result
=
BTree
Map
::
new
();
let
mut
stack
=
VecDeque
::
new
();
stack
.push_back
(
glob_result
);
while
let
Some
(
glob_result
)
=
stack
.pop_back
()
{
...
...
@@ -128,7 +129,10 @@ async fn apply_includes(
// unwrap is safe because project_root_path and ident_folder have the same filesystem
// and paths produced by read_glob stay in the filesystem
let
relative_path
=
ident_folder
.get_relative_path_to
(
file_path
)
.unwrap
();
result
.insert
(
relative_path
);
result
.insert
(
relative_path
,
file_path
.read
()
.hash
(
HashAlgorithm
::
Xxh3Hash128Hex
)
.await
?
,
);
}
for
nested_result
in
glob_result
.inner
.values
()
{
...
...
@@ -149,7 +153,7 @@ impl Asset for NftJsonAsset {
path
=
display
(
self
.path
()
.to_string
()
.await
?
)
);
async
move
{
let
mut
result
:
BTree
Set
<
RcStr
>
=
BTreeSet
::
new
();
let
mut
result
:
BTree
Map
<
RcStr
,
ReadRef
<
RcStr
>>
=
BTreeMap
::
new
();
let
project_path
=
this
.project
.project_path
()
.owned
()
.await
?
;
let
output_root_ref
=
this
.project
.output_fs
()
.root
()
.await
?
;
...
...
@@ -320,7 +324,13 @@ impl Asset for NftJsonAsset {
}
};
result
.insert
(
specifier
);
result
.insert
(
specifier
,
referenced_chunk
.content
()
.hash
(
HashAlgorithm
::
Xxh3Hash128Hex
)
.await
?
,
);
}
// Apply outputFileTracingIncludes and outputFileTracingExcludes
...
...
@@ -371,9 +381,11 @@ impl Asset for NftJsonAsset {
result
.extend
(
includes
.into_iter
()
.flatten
());
}
let
(
files
,
file_hashes
):
(
Vec
<
_
>
,
Vec
<
_
>
)
=
result
.into_iter
()
.unzip
();
let
json
=
json!
({
"version"
:
1
,
"files"
:
result
"files"
:
files
,
"fileHashes"
:
file_hashes
});
Ok
(
AssetContent
::
file
(
...
...
packages/next/src/build/adapter/build-complete.ts
View file @
7e050637
This diff is collapsed.
Click to expand it.
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