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
64f34a0e
Unverified
Commit
64f34a0e
authored
Feb 04, 2025
by
Niklas Mischkulnig
Committed by
GitHub
Feb 04, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: `OutputAsset::path()` (#75659)
parent
47bece4e
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
162 additions
and
233 deletions
+162
-233
app.rs
crates/next-api/src/app.rs
+3
-3
loadable_manifest.rs
crates/next-api/src/loadable_manifest.rs
+1
-1
nft_json.rs
crates/next-api/src/nft_json.rs
+8
-10
pages.rs
crates/next-api/src/pages.rs
+2
-2
paths.rs
crates/next-api/src/paths.rs
+2
-2
project.rs
crates/next-api/src/project.rs
+1
-1
versioned_content_map.rs
crates/next-api/src/versioned_content_map.rs
+1
-1
webpack_stats.rs
crates/next-api/src/webpack_stats.rs
+2
-2
emit.rs
crates/next-core/src/emit.rs
+3
-7
client_reference_manifest.rs
...next-core/src/next_manifests/client_reference_manifest.rs
+1
-1
mod.rs
crates/next-core/src/next_manifests/mod.rs
+4
-4
page_loader.rs
crates/next-core/src/page_loader.rs
+8
-11
chunking_context.rs
turbopack/crates/turbopack-browser/src/chunking_context.rs
+4
-5
chunk.rs
turbopack/crates/turbopack-browser/src/ecmascript/chunk.rs
+4
-4
content.rs
turbopack/crates/turbopack-browser/src/ecmascript/content.rs
+2
-2
chunk.rs
...crates/turbopack-browser/src/ecmascript/evaluate/chunk.rs
+5
-7
asset.rs
...ack/crates/turbopack-browser/src/ecmascript/list/asset.rs
+3
-4
content.rs
...k/crates/turbopack-browser/src/ecmascript/list/content.rs
+2
-2
update.rs
.../crates/turbopack-browser/src/ecmascript/merged/update.rs
+1
-1
mod.rs
turbopack/crates/turbopack-cli/src/build/mod.rs
+1
-1
chunking_context.rs
...opack/crates/turbopack-core/src/chunk/chunking_context.rs
+1
-1
data.rs
turbopack/crates/turbopack-core/src/chunk/data.rs
+2
-2
mod.rs
turbopack/crates/turbopack-core/src/chunk/mod.rs
+6
-10
output_asset.rs
...pack/crates/turbopack-core/src/introspect/output_asset.rs
+1
-1
output.rs
turbopack/crates/turbopack-core/src/output.rs
+4
-4
proxied_asset.rs
turbopack/crates/turbopack-core/src/proxied_asset.rs
+2
-3
raw_output.rs
turbopack/crates/turbopack-core/src/raw_output.rs
+2
-3
rebase.rs
turbopack/crates/turbopack-core/src/rebase.rs
+3
-4
source_map_asset.rs
.../crates/turbopack-core/src/source_map/source_map_asset.rs
+4
-5
traced_asset.rs
turbopack/crates/turbopack-core/src/traced_asset.rs
+3
-3
virtual_output.rs
turbopack/crates/turbopack-core/src/virtual_output.rs
+2
-3
mod.rs
turbopack/crates/turbopack-css/src/chunk/mod.rs
+6
-13
chunk.rs
...crates/turbopack-css/src/chunk/single_item_chunk/chunk.rs
+8
-10
source_map.rs
...s/turbopack-css/src/chunk/single_item_chunk/source_map.rs
+3
-5
source_map.rs
turbopack/crates/turbopack-css/src/chunk/source_map.rs
+3
-5
url.rs
turbopack/crates/turbopack-css/src/references/url.rs
+1
-1
html.rs
turbopack/crates/turbopack-dev-server/src/html.rs
+3
-4
asset_graph.rs
...ack/crates/turbopack-dev-server/src/source/asset_graph.rs
+2
-2
mod.rs
turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
+4
-17
chunk_group_files_asset.rs
...rates/turbopack-ecmascript/src/chunk_group_files_asset.rs
+1
-1
lib.rs
turbopack/crates/turbopack-node/src/lib.rs
+4
-14
chunking_context.rs
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
+4
-5
chunk.rs
...pack/crates/turbopack-nodejs/src/ecmascript/node/chunk.rs
+4
-4
content.rs
...ck/crates/turbopack-nodejs/src/ecmascript/node/content.rs
+2
-2
chunk.rs
...rates/turbopack-nodejs/src/ecmascript/node/entry/chunk.rs
+6
-7
runtime.rs
...tes/turbopack-nodejs/src/ecmascript/node/entry/runtime.rs
+4
-4
fixed.rs
turbopack/crates/turbopack-static/src/fixed.rs
+2
-3
lib.rs
turbopack/crates/turbopack-static/src/lib.rs
+1
-1
output_asset.rs
turbopack/crates/turbopack-static/src/output_asset.rs
+4
-6
snapshot.rs
turbopack/crates/turbopack-tests/tests/snapshot.rs
+2
-6
output_asset.rs
turbopack/crates/turbopack-wasm/src/output_asset.rs
+3
-6
raw.rs
turbopack/crates/turbopack-wasm/src/raw.rs
+1
-1
lib.rs
turbopack/crates/turbopack/src/lib.rs
+2
-2
node-file-trace.rs
turbopack/crates/turbopack/tests/node-file-trace.rs
+4
-4
No files found.
crates/next-api/src/app.rs
View file @
64f34a0e
...
@@ -1157,7 +1157,7 @@ impl AppEndpoint {
...
@@ -1157,7 +1157,7 @@ impl AppEndpoint {
for
chunk
in
client_shared_chunk_group
.assets.await
?
.iter
()
.copied
()
{
for
chunk
in
client_shared_chunk_group
.assets.await
?
.iter
()
.copied
()
{
client_assets
.insert
(
chunk
);
client_assets
.insert
(
chunk
);
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
if
chunk_path
.extension_ref
()
==
Some
(
"js"
)
{
if
chunk_path
.extension_ref
()
==
Some
(
"js"
)
{
client_shared_chunks
.push
(
chunk
);
client_shared_chunks
.push
(
chunk
);
}
}
...
@@ -1534,7 +1534,7 @@ impl AppEndpoint {
...
@@ -1534,7 +1534,7 @@ impl AppEndpoint {
&
app_entry
.original_name
,
&
app_entry
.original_name
,
server_path
server_path
.await
?
.await
?
.get_path_to
(
&*
rsc_chunk
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
rsc_chunk
.path
()
.await
?
)
.context
(
.context
(
"RSC chunk path should be within app paths manifest directory"
,
"RSC chunk path should be within app paths manifest directory"
,
)
?
)
?
...
@@ -1847,7 +1847,7 @@ impl Endpoint for AppEndpoint {
...
@@ -1847,7 +1847,7 @@ impl Endpoint for AppEndpoint {
let
written_endpoint
=
match
*
output
{
let
written_endpoint
=
match
*
output
{
AppEndpointOutput
::
NodeJs
{
rsc_chunk
,
..
}
=>
EndpointOutputPaths
::
NodeJs
{
AppEndpointOutput
::
NodeJs
{
rsc_chunk
,
..
}
=>
EndpointOutputPaths
::
NodeJs
{
server_entry_path
:
node_root_ref
server_entry_path
:
node_root_ref
.get_path_to
(
&*
rsc_chunk
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
rsc_chunk
.path
()
.await
?
)
.context
(
"Node.js chunk entry path must be inside the node root"
)
?
.context
(
"Node.js chunk entry path must be inside the node root"
)
?
.to_string
(),
.to_string
(),
server_paths
,
server_paths
,
...
...
crates/next-api/src/loadable_manifest.rs
View file @
64f34a0e
...
@@ -36,7 +36,7 @@ pub async fn create_react_loadable_manifest(
...
@@ -36,7 +36,7 @@ pub async fn create_react_loadable_manifest(
let
client_relative_path_value
=
client_relative_path_value
.clone
();
let
client_relative_path_value
=
client_relative_path_value
.clone
();
async
move
{
async
move
{
Ok
(
client_relative_path_value
Ok
(
client_relative_path_value
.get_path_to
(
&*
file
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
file
.path
()
.await
?
)
.map
(|
path
|
path
.into
()))
.map
(|
path
|
path
.into
()))
}
}
})
})
...
...
crates/next-api/src/nft_json.rs
View file @
64f34a0e
...
@@ -7,7 +7,6 @@ use turbo_tasks::{ResolvedVc, Vc};
...
@@ -7,7 +7,6 @@ use turbo_tasks::{ResolvedVc, Vc};
use
turbo_tasks_fs
::{
File
,
FileSystem
,
FileSystemPath
};
use
turbo_tasks_fs
::{
File
,
FileSystem
,
FileSystemPath
};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
reference
::
all_assets_from_entries
,
reference
::
all_assets_from_entries
,
};
};
...
@@ -60,13 +59,12 @@ impl NftJsonAsset {
...
@@ -60,13 +59,12 @@ impl NftJsonAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
NftJsonAsset
{
impl
OutputAsset
for
NftJsonAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
path
=
self
.chunk
.ident
()
.path
()
.await
?
;
let
path
=
self
.chunk
.path
()
.await
?
;
Ok
(
AssetIdent
::
from_path
(
Ok
(
path
path
.fs
.fs
.root
()
.root
()
.join
(
format!
(
"{}.nft.json"
,
path
.path
)
.into
()),
.join
(
format!
(
"{}.nft.json"
,
path
.path
)
.into
()))
))
}
}
}
}
...
@@ -121,7 +119,7 @@ impl Asset for NftJsonAsset {
...
@@ -121,7 +119,7 @@ impl Asset for NftJsonAsset {
let
client_root_ref
=
client_root
.await
?
;
let
client_root_ref
=
client_root
.await
?
;
let
dist_dir
=
self
.dist_dir
()
.await
?
;
let
dist_dir
=
self
.dist_dir
()
.await
?
;
let
ident_folder
=
self
.
ident
()
.
path
()
.parent
()
.await
?
;
let
ident_folder
=
self
.path
()
.parent
()
.await
?
;
let
ident_folder_in_project_fs
=
this
let
ident_folder_in_project_fs
=
this
.project
.project
.project_path
()
.project_path
()
...
@@ -141,7 +139,7 @@ impl Asset for NftJsonAsset {
...
@@ -141,7 +139,7 @@ impl Asset for NftJsonAsset {
continue
;
continue
;
}
}
let
referenced_chunk_path
=
referenced_chunk
.
ident
()
.
path
()
.await
?
;
let
referenced_chunk_path
=
referenced_chunk
.path
()
.await
?
;
if
referenced_chunk_path
.extension_ref
()
==
Some
(
"map"
)
{
if
referenced_chunk_path
.extension_ref
()
==
Some
(
"map"
)
{
continue
;
continue
;
}
}
...
...
crates/next-api/src/pages.rs
View file @
64f34a0e
...
@@ -1098,7 +1098,7 @@ impl PageEndpoint {
...
@@ -1098,7 +1098,7 @@ impl PageEndpoint {
entry_chunk
:
Vc
<
Box
<
dyn
OutputAsset
>>
,
entry_chunk
:
Vc
<
Box
<
dyn
OutputAsset
>>
,
)
->
Result
<
Vc
<
Box
<
dyn
OutputAsset
>>>
{
)
->
Result
<
Vc
<
Box
<
dyn
OutputAsset
>>>
{
let
node_root
=
self
.pages_project
.project
()
.node_root
();
let
node_root
=
self
.pages_project
.project
()
.node_root
();
let
chunk_path
=
entry_chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
entry_chunk
.path
()
.await
?
;
let
asset_path
=
node_root
let
asset_path
=
node_root
.join
(
"server"
.into
())
.join
(
"server"
.into
())
...
@@ -1424,7 +1424,7 @@ impl Endpoint for PageEndpoint {
...
@@ -1424,7 +1424,7 @@ impl Endpoint for PageEndpoint {
let
written_endpoint
=
match
*
output
{
let
written_endpoint
=
match
*
output
{
PageEndpointOutput
::
NodeJs
{
entry_chunk
,
..
}
=>
EndpointOutputPaths
::
NodeJs
{
PageEndpointOutput
::
NodeJs
{
entry_chunk
,
..
}
=>
EndpointOutputPaths
::
NodeJs
{
server_entry_path
:
node_root
server_entry_path
:
node_root
.get_path_to
(
&*
entry_chunk
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
entry_chunk
.path
()
.await
?
)
.context
(
"ssr chunk entry path must be inside the node root"
)
?
.context
(
"ssr chunk entry path must be inside the node root"
)
?
.to_string
(),
.to_string
(),
server_paths
,
server_paths
,
...
...
crates/next-api/src/paths.rs
View file @
64f34a0e
...
@@ -39,7 +39,7 @@ pub async fn all_server_paths(
...
@@ -39,7 +39,7 @@ pub async fn all_server_paths(
.iter
()
.iter
()
.map
(|
&
asset
|
async
move
{
.map
(|
&
asset
|
async
move
{
Ok
(
Ok
(
if
let
Some
(
path
)
=
node_root
.get_path_to
(
&*
asset
.
ident
()
.
path
()
.await
?
)
{
if
let
Some
(
path
)
=
node_root
.get_path_to
(
&*
asset
.path
()
.await
?
)
{
let
content_hash
=
match
*
asset
.content
()
.await
?
{
let
content_hash
=
match
*
asset
.content
()
.await
?
{
AssetContent
::
File
(
file
)
=>
*
file
.hash
()
.await
?
,
AssetContent
::
File
(
file
)
=>
*
file
.hash
()
.await
?
,
AssetContent
::
Redirect
{
..
}
=>
0
,
AssetContent
::
Redirect
{
..
}
=>
0
,
...
@@ -84,7 +84,7 @@ pub(crate) async fn get_paths_from_root(
...
@@ -84,7 +84,7 @@ pub(crate) async fn get_paths_from_root(
output_assets
output_assets
.iter
()
.iter
()
.map
(
move
|
&
file
|
async
move
{
.map
(
move
|
&
file
|
async
move
{
let
path
=
&*
file
.
ident
()
.
path
()
.await
?
;
let
path
=
&*
file
.path
()
.await
?
;
let
Some
(
relative
)
=
root
.get_path_to
(
path
)
else
{
let
Some
(
relative
)
=
root
.get_path_to
(
path
)
else
{
return
Ok
(
None
);
return
Ok
(
None
);
};
};
...
...
crates/next-api/src/project.rs
View file @
64f34a0e
...
@@ -1649,7 +1649,7 @@ async fn any_output_changed(
...
@@ -1649,7 +1649,7 @@ async fn any_output_changed(
.into_inner
()
.into_inner
()
.into_reverse_topological
()
.into_reverse_topological
()
.map
(|
m
|
async
move
{
.map
(|
m
|
async
move
{
let
asset_path
=
m
.
ident
()
.
path
()
.await
?
;
let
asset_path
=
m
.path
()
.await
?
;
if
!
asset_path
.path
.ends_with
(
".map"
)
if
!
asset_path
.path
.ends_with
(
".map"
)
&&
(
!
server
||
!
asset_path
.path
.ends_with
(
".css"
))
&&
(
!
server
||
!
asset_path
.path
.ends_with
(
".css"
))
&&
asset_path
.is_inside_ref
(
path
)
&&
asset_path
.is_inside_ref
(
path
)
...
...
crates/next-api/src/versioned_content_map.rs
View file @
64f34a0e
...
@@ -128,7 +128,7 @@ impl VersionedContentMap {
...
@@ -128,7 +128,7 @@ impl VersionedContentMap {
let
entries
=
assets_ref
let
entries
=
assets_ref
.iter
()
.iter
()
.map
(|
&
asset
|
async
move
{
.map
(|
&
asset
|
async
move
{
let
path
=
asset
.
ident
()
.
path
()
.to_resolved
()
.await
?
;
let
path
=
asset
.path
()
.to_resolved
()
.await
?
;
Ok
((
path
,
asset
))
Ok
((
path
,
asset
))
})
})
.try_join
()
.try_join
()
...
...
crates/next-api/src/webpack_stats.rs
View file @
64f34a0e
...
@@ -21,14 +21,14 @@ where
...
@@ -21,14 +21,14 @@ where
FxIndexMap
::
default
();
FxIndexMap
::
default
();
let
mut
modules
=
vec!
[];
let
mut
modules
=
vec!
[];
for
asset
in
entry_assets
{
for
asset
in
entry_assets
{
let
path
=
normalize_client_path
(
&
asset
.
ident
()
.
path
()
.await
?
.path
);
let
path
=
normalize_client_path
(
&
asset
.path
()
.await
?
.path
);
let
Some
(
asset_len
)
=
*
asset
.size_bytes
()
.await
?
else
{
let
Some
(
asset_len
)
=
*
asset
.size_bytes
()
.await
?
else
{
continue
;
continue
;
};
};
if
let
Some
(
chunk
)
=
ResolvedVc
::
try_downcast_type
::
<
EcmascriptDevChunk
>
(
*
asset
)
{
if
let
Some
(
chunk
)
=
ResolvedVc
::
try_downcast_type
::
<
EcmascriptDevChunk
>
(
*
asset
)
{
let
chunk_ident
=
normalize_client_path
(
&
chunk
.
ident
()
.
path
()
.await
?
.path
);
let
chunk_ident
=
normalize_client_path
(
&
chunk
.path
()
.await
?
.path
);
chunks
.push
(
WebpackStatsChunk
{
chunks
.push
(
WebpackStatsChunk
{
size
:
asset_len
,
size
:
asset_len
,
files
:
vec!
[
chunk_ident
.clone
()
.into
()],
files
:
vec!
[
chunk_ident
.clone
()
.into
()],
...
...
crates/next-core/src/emit.rs
View file @
64f34a0e
...
@@ -50,7 +50,7 @@ pub async fn emit_assets(
...
@@ -50,7 +50,7 @@ pub async fn emit_assets(
.iter
()
.iter
()
.copied
()
.copied
()
.map
(|
asset
|
async
move
{
.map
(|
asset
|
async
move
{
let
path
=
asset
.
ident
()
.
path
();
let
path
=
asset
.path
();
let
span
=
tracing
::
info_span!
(
"emit asset"
,
name
=
%
path
.to_string
()
.await
?
);
let
span
=
tracing
::
info_span!
(
"emit asset"
,
name
=
%
path
.to_string
()
.await
?
);
async
move
{
async
move
{
let
path
=
path
.await
?
;
let
path
=
path
.await
?
;
...
@@ -79,11 +79,7 @@ pub async fn emit_assets(
...
@@ -79,11 +79,7 @@ pub async fn emit_assets(
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
emit
(
asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
)
->
Result
<
()
>
{
async
fn
emit
(
asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
)
->
Result
<
()
>
{
let
_
=
asset
let
_
=
asset
.content
()
.write
(
asset
.path
())
.resolve
()
.await
?
;
.content
()
.write
(
asset
.ident
()
.path
())
.resolve
()
.await
?
;
Ok
(())
Ok
(())
}
}
...
@@ -93,7 +89,7 @@ async fn emit_rebase(
...
@@ -93,7 +89,7 @@ async fn emit_rebase(
from
:
Vc
<
FileSystemPath
>
,
from
:
Vc
<
FileSystemPath
>
,
to
:
Vc
<
FileSystemPath
>
,
to
:
Vc
<
FileSystemPath
>
,
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
path
=
rebase
(
asset
.
ident
()
.
path
(),
from
,
to
);
let
path
=
rebase
(
asset
.path
(),
from
,
to
);
let
content
=
asset
.content
();
let
content
=
asset
.content
();
let
_
=
content
let
_
=
content
.resolve
()
.resolve
()
...
...
crates/next-core/src/next_manifests/client_reference_manifest.rs
View file @
64f34a0e
...
@@ -109,7 +109,7 @@ impl ClientReferenceManifest {
...
@@ -109,7 +109,7 @@ impl ClientReferenceManifest {
Ok
(
if
let
Some
(
path
)
=
path
{
Ok
(
if
let
Some
(
path
)
=
path
{
(
chunk
,
Either
::
Left
(
path
))
(
chunk
,
Either
::
Left
(
path
))
}
else
{
}
else
{
(
chunk
,
Either
::
Right
(
chunk
.
ident
()
.
path
()
.await
?
))
(
chunk
,
Either
::
Right
(
chunk
.path
()
.await
?
))
})
})
})
})
.try_join
()
.try_join
()
...
...
crates/next-core/src/next_manifests/mod.rs
View file @
64f34a0e
...
@@ -63,7 +63,7 @@ impl BuildManifest {
...
@@ -63,7 +63,7 @@ impl BuildManifest {
.iter
()
.iter
()
.copied
()
.copied
()
.map
(|
chunk
|
async
move
{
.map
(|
chunk
|
async
move
{
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
Ok
(
client_relative_path_ref
Ok
(
client_relative_path_ref
.get_path_to
(
&
chunk_path
)
.get_path_to
(
&
chunk_path
)
.context
(
"client chunk entry path must be inside the client root"
)
?
.context
(
"client chunk entry path must be inside the client root"
)
?
...
@@ -81,7 +81,7 @@ impl BuildManifest {
...
@@ -81,7 +81,7 @@ impl BuildManifest {
.iter
()
.iter
()
.copied
()
.copied
()
.map
(|
chunk
|
async
move
{
.map
(|
chunk
|
async
move
{
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
Ok
(
client_relative_path_ref
Ok
(
client_relative_path_ref
.get_path_to
(
&
chunk_path
)
.get_path_to
(
&
chunk_path
)
.context
(
"failed to resolve client-relative path to polyfill"
)
?
.context
(
"failed to resolve client-relative path to polyfill"
)
?
...
@@ -95,7 +95,7 @@ impl BuildManifest {
...
@@ -95,7 +95,7 @@ impl BuildManifest {
.iter
()
.iter
()
.copied
()
.copied
()
.map
(|
chunk
|
async
move
{
.map
(|
chunk
|
async
move
{
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
Ok
(
client_relative_path_ref
Ok
(
client_relative_path_ref
.get_path_to
(
&
chunk_path
)
.get_path_to
(
&
chunk_path
)
.context
(
"failed to resolve client-relative path to root_main_file"
)
?
.context
(
"failed to resolve client-relative path to root_main_file"
)
?
...
@@ -448,7 +448,7 @@ impl AppBuildManifest {
...
@@ -448,7 +448,7 @@ impl AppBuildManifest {
.iter
()
.iter
()
.copied
()
.copied
()
.map
(|
chunk
|
async
move
{
.map
(|
chunk
|
async
move
{
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
Ok
(
client_relative_path_ref
Ok
(
client_relative_path_ref
.get_path_to
(
&
chunk_path
)
.get_path_to
(
&
chunk_path
)
.context
(
"client chunk entry path must be inside the client root"
)
?
.context
(
"client chunk entry path must be inside the client root"
)
?
...
...
crates/next-core/src/page_loader.rs
View file @
64f34a0e
...
@@ -10,7 +10,6 @@ use turbopack_core::{
...
@@ -10,7 +10,6 @@ use turbopack_core::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
ChunkData
,
ChunksData
},
chunk
::{
ChunkData
,
ChunksData
},
context
::
AssetContext
,
context
::
AssetContext
,
ident
::
AssetIdent
,
module
::
Module
,
module
::
Module
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
proxied_asset
::
ProxiedAsset
,
proxied_asset
::
ProxiedAsset
,
...
@@ -113,7 +112,7 @@ impl PageLoaderAsset {
...
@@ -113,7 +112,7 @@ impl PageLoaderAsset {
.map
(|
&
chunk
|
{
.map
(|
&
chunk
|
{
Vc
::
upcast
::
<
Box
<
dyn
OutputAsset
>>
(
ProxiedAsset
::
new
(
Vc
::
upcast
::
<
Box
<
dyn
OutputAsset
>>
(
ProxiedAsset
::
new
(
*
chunk
,
*
chunk
,
FileSystemPath
::
rebase
(
chunk
.
ident
()
.
path
(),
**
rebase_path
,
root_path
),
FileSystemPath
::
rebase
(
chunk
.path
(),
**
rebase_path
,
root_path
),
))
))
.to_resolved
()
.to_resolved
()
})
})
...
@@ -134,19 +133,17 @@ fn page_loader_chunk_reference_description() -> Vc<RcStr> {
...
@@ -134,19 +133,17 @@ fn page_loader_chunk_reference_description() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
PageLoaderAsset
{
impl
OutputAsset
for
PageLoaderAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
root
=
self
let
root
=
self
.rebase_prefix_path
.rebase_prefix_path
.await
?
.await
?
.map_or
(
*
self
.server_root
,
|
path
|
*
path
);
.map_or
(
*
self
.server_root
,
|
path
|
*
path
);
Ok
(
AssetIdent
::
from_path
(
Ok
(
root
.join
(
root
.join
(
format!
(
format!
(
"static/chunks/pages{}"
,
"static/chunks/pages{}"
,
get_asset_path_from_pathname
(
&
self
.pathname.await
?
,
".js"
)
get_asset_path_from_pathname
(
&
self
.pathname.await
?
,
".js"
)
)
)
.into
(),
.into
(),
),
))
))
}
}
...
...
turbopack/crates/turbopack-browser/src/chunking_context.rs
View file @
64f34a0e
...
@@ -326,17 +326,16 @@ impl ChunkingContext for BrowserChunkingContext {
...
@@ -326,17 +326,16 @@ impl ChunkingContext for BrowserChunkingContext {
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
asset_url
(
self
:
Vc
<
Self
>
,
ident
:
Vc
<
AssetIdent
>
)
->
Result
<
Vc
<
RcStr
>>
{
async
fn
asset_url
(
&
self
,
ident
:
Vc
<
FileSystemPath
>
)
->
Result
<
Vc
<
RcStr
>>
{
let
this
=
self
.await
?
;
let
asset_path
=
ident
.await
?
.to_string
();
let
asset_path
=
ident
.path
()
.await
?
.to_string
();
let
asset_path
=
asset_path
let
asset_path
=
asset_path
.strip_prefix
(
&
format!
(
"{}/"
,
this
.client_root.await
?
.path
))
.strip_prefix
(
&
format!
(
"{}/"
,
self
.client_root.await
?
.path
))
.context
(
"expected asset_path to contain client_root"
)
?
;
.context
(
"expected asset_path to contain client_root"
)
?
;
Ok
(
Vc
::
cell
(
Ok
(
Vc
::
cell
(
format!
(
format!
(
"{}{}"
,
"{}{}"
,
this
.asset_base_path
self
.asset_base_path
.await
?
.await
?
.as_ref
()
.as_ref
()
.map
(|
s
|
s
.as_str
())
.map
(|
s
|
s
.as_str
())
...
...
turbopack/crates/turbopack-browser/src/ecmascript/chunk.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
Chunk
,
ChunkingContext
,
OutputChunk
,
OutputChunkRuntimeInfo
},
chunk
::{
Chunk
,
ChunkingContext
,
OutputChunk
,
OutputChunkRuntimeInfo
},
ident
::
AssetIdent
,
introspect
::{
Introspectable
,
IntrospectableChildren
},
introspect
::{
Introspectable
,
IntrospectableChildren
},
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
...
@@ -83,9 +83,9 @@ impl EcmascriptDevChunk {
...
@@ -83,9 +83,9 @@ impl EcmascriptDevChunk {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptDevChunk
{
impl
OutputAsset
for
EcmascriptDevChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
let
ident
=
self
.chunk
.ident
()
.with_modifier
(
modifier
());
let
ident
=
self
.chunk
.ident
()
.with_modifier
(
modifier
());
AssetIdent
::
from_path
(
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()
))
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
(
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -161,7 +161,7 @@ impl Introspectable for EcmascriptDevChunk {
...
@@ -161,7 +161,7 @@ impl Introspectable for EcmascriptDevChunk {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
self
.
ident
()
.to_string
()
self
.
path
()
.to_string
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-browser/src/ecmascript/content.rs
View file @
64f34a0e
...
@@ -59,7 +59,7 @@ impl EcmascriptDevChunkContent {
...
@@ -59,7 +59,7 @@ impl EcmascriptDevChunkContent {
pub
(
crate
)
fn
own_version
(
&
self
)
->
Vc
<
EcmascriptDevChunkVersion
>
{
pub
(
crate
)
fn
own_version
(
&
self
)
->
Vc
<
EcmascriptDevChunkVersion
>
{
EcmascriptDevChunkVersion
::
new
(
EcmascriptDevChunkVersion
::
new
(
self
.chunking_context
.output_root
(),
self
.chunking_context
.output_root
(),
self
.chunk
.
ident
()
.
path
(),
self
.chunk
.path
(),
*
self
.entries
,
*
self
.entries
,
)
)
}
}
...
@@ -71,7 +71,7 @@ impl EcmascriptDevChunkContent {
...
@@ -71,7 +71,7 @@ impl EcmascriptDevChunkContent {
let
source_maps
=
this
let
source_maps
=
this
.chunking_context
.chunking_context
.reference_chunk_source_maps
(
*
ResolvedVc
::
upcast
(
this
.chunk
));
.reference_chunk_source_maps
(
*
ResolvedVc
::
upcast
(
this
.chunk
));
let
chunk_path_vc
=
this
.chunk
.
ident
()
.
path
();
let
chunk_path_vc
=
this
.chunk
.path
();
let
chunk_path
=
chunk_path_vc
.await
?
;
let
chunk_path
=
chunk_path_vc
.await
?
;
let
chunk_server_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
chunk_path
)
{
let
chunk_server_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
chunk_path
)
{
path
path
...
...
turbopack/crates/turbopack-browser/src/ecmascript/evaluate/chunk.rs
View file @
64f34a0e
...
@@ -5,7 +5,7 @@ use indoc::writedoc;
...
@@ -5,7 +5,7 @@ use indoc::writedoc;
use
serde
::
Serialize
;
use
serde
::
Serialize
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
File
;
use
turbo_tasks_fs
::
{
File
,
FileSystemPath
}
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
chunk
::{
...
@@ -79,7 +79,7 @@ impl EcmascriptDevEvaluateChunk {
...
@@ -79,7 +79,7 @@ impl EcmascriptDevEvaluateChunk {
let
source_maps
=
this
let
source_maps
=
this
.chunking_context
.chunking_context
.reference_chunk_source_maps
(
Vc
::
upcast
(
self
));
.reference_chunk_source_maps
(
Vc
::
upcast
(
self
));
let
chunk_path_vc
=
self
.
ident
()
.
path
();
let
chunk_path_vc
=
self
.path
();
let
chunk_path
=
chunk_path_vc
.await
?
;
let
chunk_path
=
chunk_path_vc
.await
?
;
let
chunk_public_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
chunk_path
)
{
let
chunk_public_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
chunk_path
)
{
path
path
...
@@ -216,7 +216,7 @@ fn modifier() -> Vc<RcStr> {
...
@@ -216,7 +216,7 @@ fn modifier() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptDevEvaluateChunk
{
impl
OutputAsset
for
EcmascriptDevEvaluateChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
mut
ident
=
self
.ident.await
?
.clone_value
();
let
mut
ident
=
self
.ident.await
?
.clone_value
();
ident
.add_modifier
(
modifier
()
.to_resolved
()
.await
?
);
ident
.add_modifier
(
modifier
()
.to_resolved
()
.await
?
);
...
@@ -234,15 +234,13 @@ impl OutputAsset for EcmascriptDevEvaluateChunk {
...
@@ -234,15 +234,13 @@ impl OutputAsset for EcmascriptDevEvaluateChunk {
self
.other_chunks
self
.other_chunks
.await
?
.await
?
.iter
()
.iter
()
.map
(|
chunk
|
chunk
.
ident
()
.to_string
()
.to_resolved
())
.map
(|
chunk
|
chunk
.
path
()
.to_string
()
.to_resolved
())
.try_join
()
.try_join
()
.await
?
,
.await
?
,
);
);
let
ident
=
AssetIdent
::
new
(
Value
::
new
(
ident
));
let
ident
=
AssetIdent
::
new
(
Value
::
new
(
ident
));
Ok
(
AssetIdent
::
from_path
(
Ok
(
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()))
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()),
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-browser/src/ecmascript/list/asset.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
ChunkingContext
,
EvaluatableAssets
},
chunk
::{
ChunkingContext
,
EvaluatableAssets
},
...
@@ -90,7 +91,7 @@ fn chunk_key() -> Vc<RcStr> {
...
@@ -90,7 +91,7 @@ fn chunk_key() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptDevChunkList
{
impl
OutputAsset
for
EcmascriptDevChunkList
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
mut
ident
=
self
.ident.await
?
.clone_value
();
let
mut
ident
=
self
.ident.await
?
.clone_value
();
ident
.add_modifier
(
modifier
()
.to_resolved
()
.await
?
);
ident
.add_modifier
(
modifier
()
.to_resolved
()
.await
?
);
...
@@ -106,9 +107,7 @@ impl OutputAsset for EcmascriptDevChunkList {
...
@@ -106,9 +107,7 @@ impl OutputAsset for EcmascriptDevChunkList {
// removed from the list.
// removed from the list.
let
ident
=
AssetIdent
::
new
(
Value
::
new
(
ident
));
let
ident
=
AssetIdent
::
new
(
Value
::
new
(
ident
));
Ok
(
AssetIdent
::
from_path
(
Ok
(
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()))
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()),
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-browser/src/ecmascript/list/content.rs
View file @
64f34a0e
...
@@ -39,7 +39,7 @@ impl EcmascriptDevChunkListContent {
...
@@ -39,7 +39,7 @@ impl EcmascriptDevChunkListContent {
let
output_root
=
chunk_list_ref
.chunking_context
.output_root
()
.await
?
;
let
output_root
=
chunk_list_ref
.chunking_context
.output_root
()
.await
?
;
Ok
(
EcmascriptDevChunkListContent
{
Ok
(
EcmascriptDevChunkListContent
{
chunk_list_path
:
output_root
chunk_list_path
:
output_root
.get_path_to
(
&*
chunk_list
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
chunk_list
.path
()
.await
?
)
.context
(
"chunk list path not in output root"
)
?
.context
(
"chunk list path not in output root"
)
?
.to_string
(),
.to_string
(),
chunks_contents
:
chunk_list_ref
chunks_contents
:
chunk_list_ref
...
@@ -51,7 +51,7 @@ impl EcmascriptDevChunkListContent {
...
@@ -51,7 +51,7 @@ impl EcmascriptDevChunkListContent {
async
move
{
async
move
{
Ok
((
Ok
((
output_root
output_root
.get_path_to
(
&*
chunk
.
ident
()
.
path
()
.await
?
)
.get_path_to
(
&*
chunk
.path
()
.await
?
)
.map
(|
path
|
path
.to_string
()),
.map
(|
path
|
path
.to_string
()),
chunk
.versioned_content
()
.to_resolved
()
.await
?
,
chunk
.versioned_content
()
.to_resolved
()
.await
?
,
))
))
...
...
turbopack/crates/turbopack-browser/src/ecmascript/merged/update.rs
View file @
64f34a0e
...
@@ -180,7 +180,7 @@ pub(super) async fn update_ecmascript_merged_chunk(
...
@@ -180,7 +180,7 @@ pub(super) async fn update_ecmascript_merged_chunk(
.map
(|
content
|
async
move
{
.map
(|
content
|
async
move
{
let
content_ref
=
content
.await
?
;
let
content_ref
=
content
.await
?
;
let
output_root
=
content_ref
.chunking_context
.output_root
()
.await
?
;
let
output_root
=
content_ref
.chunking_context
.output_root
()
.await
?
;
let
path
=
content_ref
.chunk
.
ident
()
.
path
()
.await
?
;
let
path
=
content_ref
.chunk
.path
()
.await
?
;
Ok
((
*
content
,
content_ref
,
output_root
,
path
))
Ok
((
*
content
,
content_ref
,
output_root
,
path
))
})
})
.try_join
()
.try_join
()
...
...
turbopack/crates/turbopack-cli/src/build/mod.rs
View file @
64f34a0e
...
@@ -445,7 +445,7 @@ async fn build_internal(
...
@@ -445,7 +445,7 @@ async fn build_internal(
chunks
chunks
.iter
()
.iter
()
.map
(|
c
|
c
.content
()
.write
(
c
.
ident
()
.
path
()))
.map
(|
c
|
c
.content
()
.write
(
c
.path
()))
.try_join
()
.try_join
()
.await
?
;
.await
?
;
...
...
turbopack/crates/turbopack-core/src/chunk/chunking_context.rs
View file @
64f34a0e
...
@@ -145,7 +145,7 @@ pub trait ChunkingContext {
...
@@ -145,7 +145,7 @@ pub trait ChunkingContext {
/// Returns a URL (relative or absolute, depending on the asset prefix) to
/// Returns a URL (relative or absolute, depending on the asset prefix) to
/// the static asset based on its `ident`.
/// the static asset based on its `ident`.
fn
asset_url
(
self
:
Vc
<
Self
>
,
ident
:
Vc
<
AssetIdent
>
)
->
Result
<
Vc
<
RcStr
>>
;
fn
asset_url
(
self
:
Vc
<
Self
>
,
ident
:
Vc
<
FileSystemPath
>
)
->
Result
<
Vc
<
RcStr
>>
;
fn
asset_path
(
fn
asset_path
(
self
:
Vc
<
Self
>
,
self
:
Vc
<
Self
>
,
...
...
turbopack/crates/turbopack-core/src/chunk/data.rs
View file @
64f34a0e
...
@@ -40,7 +40,7 @@ impl ChunkData {
...
@@ -40,7 +40,7 @@ impl ChunkData {
chunk
:
Vc
<
Box
<
dyn
OutputAsset
>>
,
chunk
:
Vc
<
Box
<
dyn
OutputAsset
>>
,
)
->
Result
<
Vc
<
ChunkDataOption
>>
{
)
->
Result
<
Vc
<
ChunkDataOption
>>
{
let
output_root
=
output_root
.await
?
;
let
output_root
=
output_root
.await
?
;
let
path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
path
=
chunk
.path
()
.await
?
;
// The "path" in this case is the chunk's path, not the chunk item's path.
// The "path" in this case is the chunk's path, not the chunk item's path.
// The difference is a chunk is a file served by the dev server, and an
// The difference is a chunk is a file served by the dev server, and an
// item is one of several that are contained in that chunk file.
// item is one of several that are contained in that chunk file.
...
@@ -91,7 +91,7 @@ impl ChunkData {
...
@@ -91,7 +91,7 @@ impl ChunkData {
let
output_root
=
output_root
.clone
();
let
output_root
=
output_root
.clone
();
async
move
{
async
move
{
let
chunk_path
=
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
chunk
.path
()
.await
?
;
Ok
(
output_root
Ok
(
output_root
.get_path_to
(
&
chunk_path
)
.get_path_to
(
&
chunk_path
)
.map
(|
path
|
(
path
.to_owned
(),
chunk
)))
.map
(|
path
|
(
path
.to_owned
(),
chunk
)))
...
...
turbopack/crates/turbopack-core/src/chunk/mod.rs
View file @
64f34a0e
...
@@ -19,7 +19,6 @@ use turbo_tasks::{
...
@@ -19,7 +19,6 @@ use turbo_tasks::{
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
FxIndexMap
,
FxIndexSet
,
NonLocalValue
,
ResolvedVc
,
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
FxIndexMap
,
FxIndexSet
,
NonLocalValue
,
ResolvedVc
,
TaskInput
,
Upcast
,
ValueToString
,
Vc
,
TaskInput
,
Upcast
,
ValueToString
,
Vc
,
};
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_hash
::
DeterministicHash
;
use
turbo_tasks_hash
::
DeterministicHash
;
pub
use
self
::{
pub
use
self
::{
...
@@ -107,19 +106,16 @@ impl Chunks {
...
@@ -107,19 +106,16 @@ impl Chunks {
}
}
}
}
/// A
chunk is one type of asset
.
/// A
[Chunk] group chunk items together into something that will become an [OutputAsset]
.
/// It usually contains multiple chunk items.
/// It usually contains multiple chunk items.
// TODO This could be simplified to and merged with [OutputChunk]
#[turbo_tasks
::
value_trait]
#[turbo_tasks
::
value_trait]
pub
trait
Chunk
:
Asset
{
pub
trait
Chunk
{
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
;
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
;
fn
chunking_context
(
self
:
Vc
<
Self
>
)
->
Vc
<
Box
<
dyn
ChunkingContext
>>
;
fn
chunking_context
(
self
:
Vc
<
Self
>
)
->
Vc
<
Box
<
dyn
ChunkingContext
>>
;
// TODO Once output assets have their own trait, this path() method will move
// fn path(self: Vc<Self>) -> Vc<FileSystemPath> {
// into that trait and ident() will be removed from that. Assets on the
// self.ident().path()
// output-level only have a path and no complex ident.
// }
/// The path of the chunk.
fn
path
(
self
:
Vc
<
Self
>
)
->
Vc
<
FileSystemPath
>
{
self
.ident
()
.path
()
}
/// Other [OutputAsset]s referenced from this [Chunk].
/// Other [OutputAsset]s referenced from this [Chunk].
fn
references
(
self
:
Vc
<
Self
>
)
->
Vc
<
OutputAssets
>
{
fn
references
(
self
:
Vc
<
Self
>
)
->
Vc
<
OutputAssets
>
{
...
...
turbopack/crates/turbopack-core/src/introspect/output_asset.rs
View file @
64f34a0e
...
@@ -39,7 +39,7 @@ impl Introspectable for IntrospectableOutputAsset {
...
@@ -39,7 +39,7 @@ impl Introspectable for IntrospectableOutputAsset {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
title
(
&
self
)
->
Vc
<
RcStr
>
{
fn
title
(
&
self
)
->
Vc
<
RcStr
>
{
self
.
0
.
ident
()
.to_string
()
self
.
0
.
path
()
.to_string
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-core/src/output.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
crate
::
{
asset
::
Asset
,
ident
::
AssetIdent
}
;
use
crate
::
asset
::
Asset
;
#[turbo_tasks
::
value(transparent)]
#[turbo_tasks
::
value(transparent)]
pub
struct
OptionOutputAsset
(
Option
<
ResolvedVc
<
Box
<
dyn
OutputAsset
>>>
);
pub
struct
OptionOutputAsset
(
Option
<
ResolvedVc
<
Box
<
dyn
OutputAsset
>>>
);
...
@@ -10,10 +11,9 @@ pub struct OptionOutputAsset(Option<ResolvedVc<Box<dyn OutputAsset>>>);
...
@@ -10,10 +11,9 @@ pub struct OptionOutputAsset(Option<ResolvedVc<Box<dyn OutputAsset>>>);
/// server.
/// server.
#[turbo_tasks
::
value_trait]
#[turbo_tasks
::
value_trait]
pub
trait
OutputAsset
:
Asset
{
pub
trait
OutputAsset
:
Asset
{
// TODO change this to path() -> Vc<FileSystemPath>
/// The identifier of the [OutputAsset]. It's expected to be unique and
/// The identifier of the [OutputAsset]. It's expected to be unique and
/// capture all properties of the [OutputAsset].
Only path must be used.
/// capture all properties of the [OutputAsset].
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
;
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
;
/// Other references [OutputAsset]s from this [OutputAsset].
/// Other references [OutputAsset]s from this [OutputAsset].
fn
references
(
self
:
Vc
<
Self
>
)
->
Vc
<
OutputAssets
>
{
fn
references
(
self
:
Vc
<
Self
>
)
->
Vc
<
OutputAssets
>
{
...
...
turbopack/crates/turbopack-core/src/proxied_asset.rs
View file @
64f34a0e
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
version
::
VersionedContent
,
version
::
VersionedContent
,
};
};
...
@@ -34,8 +33,8 @@ impl ProxiedAsset {
...
@@ -34,8 +33,8 @@ impl ProxiedAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
ProxiedAsset
{
impl
OutputAsset
for
ProxiedAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.path
)
*
self
.path
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-core/src/raw_output.rs
View file @
64f34a0e
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source
::
Source
,
source
::
Source
,
};
};
...
@@ -19,8 +18,8 @@ pub struct RawOutput {
...
@@ -19,8 +18,8 @@ pub struct RawOutput {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
RawOutput
{
impl
OutputAsset
for
RawOutput
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.path
)
*
self
.path
}
}
}
}
...
...
turbopack/crates/turbopack-core/src/rebase.rs
View file @
64f34a0e
...
@@ -6,7 +6,6 @@ use turbo_tasks_fs::FileSystemPath;
...
@@ -6,7 +6,6 @@ use turbo_tasks_fs::FileSystemPath;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
module
::
Module
,
module
::
Module
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
reference
::
referenced_modules_and_affecting_sources
,
reference
::
referenced_modules_and_affecting_sources
,
...
@@ -41,12 +40,12 @@ impl RebasedAsset {
...
@@ -41,12 +40,12 @@ impl RebasedAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
RebasedAsset
{
impl
OutputAsset
for
RebasedAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
FileSystemPath
::
rebase
(
FileSystemPath
::
rebase
(
self
.module
.ident
()
.path
(),
self
.module
.ident
()
.path
(),
*
self
.input_dir
,
*
self
.input_dir
,
*
self
.output_dir
,
*
self
.output_dir
,
)
)
)
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-core/src/source_map/source_map_asset.rs
View file @
64f34a0e
use
anyhow
::{
bail
,
Result
};
use
anyhow
::{
bail
,
Result
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
File
;
use
turbo_tasks_fs
::
{
File
,
FileSystemPath
}
;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
introspect
::{
Introspectable
,
IntrospectableChildren
},
introspect
::{
Introspectable
,
IntrospectableChildren
},
output
::
OutputAsset
,
output
::
OutputAsset
,
source_map
::{
GenerateSourceMap
,
SourceMap
},
source_map
::{
GenerateSourceMap
,
SourceMap
},
...
@@ -28,10 +27,10 @@ impl SourceMapAsset {
...
@@ -28,10 +27,10 @@ impl SourceMapAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
SourceMapAsset
{
impl
OutputAsset
for
SourceMapAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
// NOTE(alexkirsz) We used to include the asset's version id in the path,
// NOTE(alexkirsz) We used to include the asset's version id in the path,
// but this caused `all_assets_map` to be recomputed on every change.
// but this caused `all_assets_map` to be recomputed on every change.
AssetIdent
::
from_path
(
self
.asset
.ident
()
.path
()
.append
(
".map"
.into
()
))
self
.asset
.path
()
.append
(
".map"
.into
(
))
}
}
}
}
...
@@ -73,7 +72,7 @@ impl Introspectable for SourceMapAsset {
...
@@ -73,7 +72,7 @@ impl Introspectable for SourceMapAsset {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
self
.
ident
()
.to_string
()
self
.
path
()
.to_string
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-core/src/traced_asset.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_tasks
::{
ResolvedVc
,
TryJoinIterExt
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
TryJoinIterExt
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
module
::
Module
,
module
::
Module
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
reference
::
referenced_modules_and_affecting_sources
,
reference
::
referenced_modules_and_affecting_sources
,
...
@@ -26,8 +26,8 @@ impl TracedAsset {
...
@@ -26,8 +26,8 @@ impl TracedAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
TracedAsset
{
impl
OutputAsset
for
TracedAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
self
.module
.ident
()
.path
()
)
self
.module
.ident
()
.path
(
)
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-core/src/virtual_output.rs
View file @
64f34a0e
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
...
@@ -3,7 +3,6 @@ use turbo_tasks_fs::FileSystemPath;
use
crate
::{
use
crate
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
};
};
...
@@ -46,8 +45,8 @@ impl VirtualOutputAsset {
...
@@ -46,8 +45,8 @@ impl VirtualOutputAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
VirtualOutputAsset
{
impl
OutputAsset
for
VirtualOutputAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.path
)
*
self
.path
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-css/src/chunk/mod.rs
View file @
64f34a0e
...
@@ -6,7 +6,7 @@ use std::fmt::Write;
...
@@ -6,7 +6,7 @@ use std::fmt::Write;
use
anyhow
::{
bail
,
Result
};
use
anyhow
::{
bail
,
Result
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
TryJoinIterExt
,
Value
,
ValueDefault
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
TryJoinIterExt
,
Value
,
ValueDefault
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::{
rope
::
Rope
,
File
,
FileSystem
};
use
turbo_tasks_fs
::{
rope
::
Rope
,
File
,
FileSystem
,
FileSystemPath
};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
chunk
::{
...
@@ -170,19 +170,13 @@ pub struct CssChunkContent {
...
@@ -170,19 +170,13 @@ pub struct CssChunkContent {
impl
Chunk
for
CssChunk
{
impl
Chunk
for
CssChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
{
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
{
let
self_as_output_asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
=
Vc
::
upcast
(
self
);
AssetIdent
::
from_path
(
self
.path
())
self_as_output_asset
.ident
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
chunking_context
(
&
self
)
->
Vc
<
Box
<
dyn
ChunkingContext
>>
{
fn
chunking_context
(
&
self
)
->
Vc
<
Box
<
dyn
ChunkingContext
>>
{
*
self
.chunking_context
*
self
.chunking_context
}
}
#[turbo_tasks
::
function]
fn
references
(
self
:
Vc
<
Self
>
)
->
Vc
<
OutputAssets
>
{
OutputAsset
::
references
(
self
)
}
}
}
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
...
@@ -252,7 +246,7 @@ fn chunk_item_key() -> Vc<RcStr> {
...
@@ -252,7 +246,7 @@ fn chunk_item_key() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
CssChunk
{
impl
OutputAsset
for
CssChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
CssChunkContent
{
chunk_items
,
..
}
=
&*
self
.content.await
?
;
let
CssChunkContent
{
chunk_items
,
..
}
=
&*
self
.content.await
?
;
let
mut
common_path
=
if
let
Some
(
chunk_item
)
=
chunk_items
.first
()
{
let
mut
common_path
=
if
let
Some
(
chunk_item
)
=
chunk_items
.first
()
{
let
path
=
chunk_item
.asset_ident
()
.path
()
.to_resolved
()
.await
?
;
let
path
=
chunk_item
.asset_ident
()
.path
()
.to_resolved
()
.await
?
;
...
@@ -303,10 +297,9 @@ impl OutputAsset for CssChunk {
...
@@ -303,10 +297,9 @@ impl OutputAsset for CssChunk {
layer
:
None
,
layer
:
None
,
};
};
Ok
(
AssetIdent
::
from_path
(
self
.chunking_context
.chunk_path
(
Ok
(
self
AssetIdent
::
new
(
Value
::
new
(
ident
)),
.chunking_context
".css"
.into
(),
.chunk_path
(
AssetIdent
::
new
(
Value
::
new
(
ident
)),
".css"
.into
()))
)))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-css/src/chunk/single_item_chunk/chunk.rs
View file @
64f34a0e
...
@@ -3,7 +3,7 @@ use std::fmt::Write;
...
@@ -3,7 +3,7 @@ use std::fmt::Write;
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
File
;
use
turbo_tasks_fs
::
{
File
,
FileSystemPath
}
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
Chunk
,
ChunkItem
,
ChunkingContext
},
chunk
::{
Chunk
,
ChunkItem
,
ChunkingContext
},
...
@@ -87,7 +87,7 @@ impl Chunk for SingleItemCssChunk {
...
@@ -87,7 +87,7 @@ impl Chunk for SingleItemCssChunk {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
{
fn
ident
(
self
:
Vc
<
Self
>
)
->
Vc
<
AssetIdent
>
{
let
self_as_output_asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
=
Vc
::
upcast
(
self
);
let
self_as_output_asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
=
Vc
::
upcast
(
self
);
self_as_output_asset
.ident
(
)
AssetIdent
::
from_path
(
self_as_output_asset
.path
()
)
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -104,14 +104,12 @@ fn single_item_modifier() -> Vc<RcStr> {
...
@@ -104,14 +104,12 @@ fn single_item_modifier() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
SingleItemCssChunk
{
impl
OutputAsset
for
SingleItemCssChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
self
.chunking_context
.chunk_path
(
self
.chunking_context
.chunk_path
(
self
.item
self
.item
.asset_ident
()
.asset_ident
()
.with_modifier
(
single_item_modifier
()),
.with_modifier
(
single_item_modifier
()),
".css"
.into
(),
".css"
.into
(),
),
)
)
}
}
...
...
turbopack/crates/turbopack-css/src/chunk/single_item_chunk/source_map.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::
File
;
use
turbo_tasks_fs
::
{
File
,
FileSystemPath
}
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::
Chunk
,
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source_map
::{
GenerateSourceMap
,
SourceMap
},
source_map
::{
GenerateSourceMap
,
SourceMap
},
};
};
...
@@ -28,8 +26,8 @@ impl SingleItemCssChunkSourceMapAsset {
...
@@ -28,8 +26,8 @@ impl SingleItemCssChunkSourceMapAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
SingleItemCssChunkSourceMapAsset
{
impl
OutputAsset
for
SingleItemCssChunkSourceMapAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
self
.chunk
.path
()
.append
(
".map"
.into
()
))
self
.chunk
.path
()
.append
(
".map"
.into
(
))
}
}
}
}
...
...
turbopack/crates/turbopack-css/src/chunk/source_map.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::
File
;
use
turbo_tasks_fs
::
{
File
,
FileSystemPath
}
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::
Chunk
,
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source_map
::{
GenerateSourceMap
,
SourceMap
},
source_map
::{
GenerateSourceMap
,
SourceMap
},
};
};
...
@@ -28,8 +26,8 @@ impl CssChunkSourceMapAsset {
...
@@ -28,8 +26,8 @@ impl CssChunkSourceMapAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
CssChunkSourceMapAsset
{
impl
OutputAsset
for
CssChunkSourceMapAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
self
.chunk
.path
()
.append
(
".map"
.into
()
))
self
.chunk
.path
()
.append
(
".map"
.into
(
))
}
}
}
}
...
...
turbopack/crates/turbopack-css/src/references/url.rs
View file @
64f34a0e
...
@@ -136,7 +136,7 @@ pub async fn resolve_url_reference(
...
@@ -136,7 +136,7 @@ pub async fn resolve_url_reference(
{
{
// TODO(WEB-662) This is not the correct way to get the path of the asset.
// TODO(WEB-662) This is not the correct way to get the path of the asset.
// `asset` is on module-level, but we need the output-level asset instead.
// `asset` is on module-level, but we need the output-level asset instead.
let
path
=
asset
.
ident
()
.
path
()
.await
?
;
let
path
=
asset
.path
()
.await
?
;
let
relative_path
=
context_path
let
relative_path
=
context_path
.get_relative_path_to
(
&
path
)
.get_relative_path_to
(
&
path
)
.unwrap_or_else
(||
format!
(
"/{}"
,
path
.path
)
.into
());
.unwrap_or_else
(||
format!
(
"/{}"
,
path
.path
)
.into
());
...
...
turbopack/crates/turbopack-dev-server/src/html.rs
View file @
64f34a0e
...
@@ -13,7 +13,6 @@ use turbopack_core::{
...
@@ -13,7 +13,6 @@ use turbopack_core::{
availability_info
::
AvailabilityInfo
,
ChunkableModule
,
ChunkingContext
,
ChunkingContextExt
,
availability_info
::
AvailabilityInfo
,
ChunkableModule
,
ChunkingContext
,
ChunkingContextExt
,
EvaluatableAssets
,
EvaluatableAssets
,
},
},
ident
::
AssetIdent
,
module
::
Module
,
module
::
Module
,
module_graph
::
ModuleGraph
,
module_graph
::
ModuleGraph
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
...
@@ -49,8 +48,8 @@ fn dev_html_chunk_reference_description() -> Vc<RcStr> {
...
@@ -49,8 +48,8 @@ fn dev_html_chunk_reference_description() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
DevHtmlAsset
{
impl
OutputAsset
for
DevHtmlAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.path
)
*
self
.path
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -123,7 +122,7 @@ impl DevHtmlAsset {
...
@@ -123,7 +122,7 @@ impl DevHtmlAsset {
let
context_path
=
this
.path
.parent
()
.await
?
;
let
context_path
=
this
.path
.parent
()
.await
?
;
let
mut
chunk_paths
=
vec!
[];
let
mut
chunk_paths
=
vec!
[];
for
chunk
in
&*
self
.chunks
()
.await
?
{
for
chunk
in
&*
self
.chunks
()
.await
?
{
let
chunk_path
=
&*
chunk
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
&*
chunk
.path
()
.await
?
;
if
let
Some
(
relative_path
)
=
context_path
.get_path_to
(
chunk_path
)
{
if
let
Some
(
relative_path
)
=
context_path
.get_path_to
(
chunk_path
)
{
chunk_paths
.push
(
format!
(
"/{relative_path}"
)
.into
());
chunk_paths
.push
(
format!
(
"/{relative_path}"
)
.into
());
}
}
...
...
turbopack/crates/turbopack-dev-server/src/source/asset_graph.rs
View file @
64f34a0e
...
@@ -113,7 +113,7 @@ async fn expand(
...
@@ -113,7 +113,7 @@ async fn expand(
let
root_assets_with_path
=
root_assets
let
root_assets_with_path
=
root_assets
.iter
()
.iter
()
.map
(|
&
asset
|
async
move
{
.map
(|
&
asset
|
async
move
{
let
path
=
asset
.
ident
()
.
path
()
.await
?
;
let
path
=
asset
.path
()
.await
?
;
Ok
((
path
,
asset
))
Ok
((
path
,
asset
))
})
})
.try_join
()
.try_join
()
...
@@ -153,7 +153,7 @@ async fn expand(
...
@@ -153,7 +153,7 @@ async fn expand(
while
let
Some
(
references
)
=
queue
.pop_front
()
{
while
let
Some
(
references
)
=
queue
.pop_front
()
{
for
asset
in
references
.await
?
.iter
()
{
for
asset
in
references
.await
?
.iter
()
{
if
assets_set
.insert
(
*
asset
)
{
if
assets_set
.insert
(
*
asset
)
{
let
path
=
asset
.
ident
()
.
path
()
.await
?
;
let
path
=
asset
.path
()
.await
?
;
if
let
Some
(
sub_path
)
=
root_path
.get_path_to
(
&
path
)
{
if
let
Some
(
sub_path
)
=
root_path
.get_path_to
(
&
path
)
{
let
(
sub_paths_buffer
,
sub_paths
)
=
get_sub_paths
(
sub_path
);
let
(
sub_paths_buffer
,
sub_paths
)
=
get_sub_paths
(
sub_path
);
let
expanded
=
if
let
Some
(
expanded
)
=
&
expanded
{
let
expanded
=
if
let
Some
(
expanded
)
=
&
expanded
{
...
...
turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
View file @
64f34a0e
...
@@ -6,18 +6,16 @@ pub(crate) mod placeable;
...
@@ -6,18 +6,16 @@ pub(crate) mod placeable;
use
std
::
fmt
::
Write
;
use
std
::
fmt
::
Write
;
use
anyhow
::
{
bail
,
Result
}
;
use
anyhow
::
Result
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystem
;
use
turbo_tasks_fs
::
FileSystem
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
chunk
::{
Chunk
,
ChunkItem
,
ChunkItems
,
ChunkingContext
,
ModuleIds
},
chunk
::{
Chunk
,
ChunkItem
,
ChunkItems
,
ChunkingContext
,
ModuleIds
},
ident
::
AssetIdent
,
ident
::
AssetIdent
,
introspect
::{
introspect
::{
module
::
IntrospectableModule
,
module
::
IntrospectableModule
,
utils
::
children_from_output_assets
,
Introspectable
,
utils
::{
children_from_output_assets
,
content_to_details
},
IntrospectableChildren
,
Introspectable
,
IntrospectableChildren
,
},
},
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
server_fs
::
ServerFileSystem
,
server_fs
::
ServerFileSystem
,
...
@@ -182,14 +180,6 @@ impl EcmascriptChunk {
...
@@ -182,14 +180,6 @@ impl EcmascriptChunk {
}
}
}
}
#[turbo_tasks
::
value_impl]
impl
Asset
for
EcmascriptChunk
{
#[turbo_tasks
::
function]
fn
content
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
AssetContent
>>
{
bail!
(
"EcmascriptChunk::content() is not implemented"
)
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
introspectable_type
()
->
Vc
<
RcStr
>
{
fn
introspectable_type
()
->
Vc
<
RcStr
>
{
Vc
::
cell
(
"ecmascript chunk"
.into
())
Vc
::
cell
(
"ecmascript chunk"
.into
())
...
@@ -209,20 +199,17 @@ impl Introspectable for EcmascriptChunk {
...
@@ -209,20 +199,17 @@ impl Introspectable for EcmascriptChunk {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
self
.
path
()
.to_string
()
self
.
ident
()
.to_string
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
details
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
RcStr
>>
{
async
fn
details
(
self
:
Vc
<
Self
>
)
->
Result
<
Vc
<
RcStr
>>
{
let
content
=
content_to_details
(
self
.content
());
let
mut
details
=
String
::
new
();
let
mut
details
=
String
::
new
();
let
this
=
self
.await
?
;
let
this
=
self
.await
?
;
details
+=
"Chunk items:
\n\n
"
;
details
+=
"Chunk items:
\n\n
"
;
for
chunk_item
in
this
.content
.included_chunk_items
()
.await
?
{
for
chunk_item
in
this
.content
.included_chunk_items
()
.await
?
{
writeln!
(
details
,
"- {}"
,
chunk_item
.asset_ident
()
.to_string
()
.await
?
)
?
;
writeln!
(
details
,
"- {}"
,
chunk_item
.asset_ident
()
.to_string
()
.await
?
)
?
;
}
}
details
+=
"
\n
Content:
\n\n
"
;
write!
(
details
,
"{}"
,
content
.await
?
)
?
;
Ok
(
Vc
::
cell
(
details
.into
()))
Ok
(
Vc
::
cell
(
details
.into
()))
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs
View file @
64f34a0e
...
@@ -180,7 +180,7 @@ impl EcmascriptChunkItem for ChunkGroupFilesChunkItem {
...
@@ -180,7 +180,7 @@ impl EcmascriptChunkItem for ChunkGroupFilesChunkItem {
let
chunks_paths
=
chunks
let
chunks_paths
=
chunks
.await
?
.await
?
.iter
()
.iter
()
.map
(|
chunk
|
chunk
.
ident
()
.
path
())
.map
(|
chunk
|
chunk
.path
())
.try_join
()
.try_join
()
.await
?
;
.await
?
;
let
chunks_paths
:
Vec
<
_
>
=
chunks_paths
let
chunks_paths
:
Vec
<
_
>
=
chunks_paths
...
...
turbopack/crates/turbopack-node/src/lib.rs
View file @
64f34a0e
...
@@ -46,11 +46,7 @@ async fn emit(
...
@@ -46,11 +46,7 @@ async fn emit(
intermediate_output_path
:
Vc
<
FileSystemPath
>
,
intermediate_output_path
:
Vc
<
FileSystemPath
>
,
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
for
asset
in
internal_assets
(
intermediate_asset
,
intermediate_output_path
)
.await
?
{
for
asset
in
internal_assets
(
intermediate_asset
,
intermediate_output_path
)
.await
?
{
let
_
=
asset
let
_
=
asset
.content
()
.write
(
asset
.path
())
.resolve
()
.await
?
;
.content
()
.write
(
asset
.ident
()
.path
())
.resolve
()
.await
?
;
}
}
Ok
(())
Ok
(())
}
}
...
@@ -97,8 +93,7 @@ async fn internal_assets_for_source_mapping(
...
@@ -97,8 +93,7 @@ async fn internal_assets_for_source_mapping(
if
let
Some
(
generate_source_map
)
=
if
let
Some
(
generate_source_map
)
=
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
GenerateSourceMap
>>
(
*
asset
)
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
GenerateSourceMap
>>
(
*
asset
)
{
{
if
let
Some
(
path
)
=
intermediate_output_path
.get_path_to
(
&*
asset
.ident
()
.path
()
.await
?
)
if
let
Some
(
path
)
=
intermediate_output_path
.get_path_to
(
&*
asset
.path
()
.await
?
)
{
{
internal_assets_for_source_mapping
.insert
(
path
.to_string
(),
generate_source_map
);
internal_assets_for_source_mapping
.insert
(
path
.to_string
(),
generate_source_map
);
}
}
}
}
...
@@ -152,12 +147,7 @@ async fn separate_assets_operation(
...
@@ -152,12 +147,7 @@ async fn separate_assets_operation(
// others as "external". We follow references on "internal" assets, but do not
// others as "external". We follow references on "internal" assets, but do not
// look into references of "external" assets, since there are no "internal"
// look into references of "external" assets, since there are no "internal"
// assets behind "externals"
// assets behind "externals"
if
asset
if
asset
.path
()
.await
?
.is_inside_ref
(
intermediate_output_path
)
{
.ident
()
.path
()
.await
?
.is_inside_ref
(
intermediate_output_path
)
{
Ok
(
Type
::
Internal
(
*
asset
))
Ok
(
Type
::
Internal
(
*
asset
))
}
else
{
}
else
{
Ok
(
Type
::
External
(
*
asset
))
Ok
(
Type
::
External
(
*
asset
))
...
@@ -225,7 +215,7 @@ pub async fn get_renderer_pool_operation(
...
@@ -225,7 +215,7 @@ pub async fn get_renderer_pool_operation(
let
assets_for_source_mapping
=
let
assets_for_source_mapping
=
internal_assets_for_source_mapping
(
*
intermediate_asset
,
*
output_root
);
internal_assets_for_source_mapping
(
*
intermediate_asset
,
*
output_root
);
let
entrypoint
=
intermediate_asset
.
ident
()
.
path
();
let
entrypoint
=
intermediate_asset
.path
();
let
Some
(
cwd
)
=
to_sys_path
(
*
cwd
)
.await
?
else
{
let
Some
(
cwd
)
=
to_sys_path
(
*
cwd
)
.await
?
else
{
bail!
(
bail!
(
...
...
turbopack/crates/turbopack-nodejs/src/chunking_context.rs
View file @
64f34a0e
...
@@ -249,17 +249,16 @@ impl ChunkingContext for NodeJsChunkingContext {
...
@@ -249,17 +249,16 @@ impl ChunkingContext for NodeJsChunkingContext {
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
asset_url
(
self
:
Vc
<
Self
>
,
ident
:
Vc
<
AssetIdent
>
)
->
Result
<
Vc
<
RcStr
>>
{
async
fn
asset_url
(
&
self
,
ident
:
Vc
<
FileSystemPath
>
)
->
Result
<
Vc
<
RcStr
>>
{
let
this
=
self
.await
?
;
let
asset_path
=
ident
.await
?
.to_string
();
let
asset_path
=
ident
.path
()
.await
?
.to_string
();
let
asset_path
=
asset_path
let
asset_path
=
asset_path
.strip_prefix
(
&
format!
(
"{}/"
,
this
.client_root.await
?
.path
))
.strip_prefix
(
&
format!
(
"{}/"
,
self
.client_root.await
?
.path
))
.context
(
"expected client root to contain asset path"
)
?
;
.context
(
"expected client root to contain asset path"
)
?
;
Ok
(
Vc
::
cell
(
Ok
(
Vc
::
cell
(
format!
(
format!
(
"{}{}"
,
"{}{}"
,
this
.asset_prefix
self
.asset_prefix
.await
?
.await
?
.as_ref
()
.as_ref
()
.map
(|
s
|
s
.clone
())
.map
(|
s
|
s
.clone
())
...
...
turbopack/crates/turbopack-nodejs/src/ecmascript/node/chunk.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
FxIndexSet
,
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
Chunk
,
ChunkingContext
},
chunk
::{
Chunk
,
ChunkingContext
},
ident
::
AssetIdent
,
introspect
::{
Introspectable
,
IntrospectableChildren
},
introspect
::{
Introspectable
,
IntrospectableChildren
},
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
...
@@ -67,9 +67,9 @@ impl EcmascriptBuildNodeChunk {
...
@@ -67,9 +67,9 @@ impl EcmascriptBuildNodeChunk {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptBuildNodeChunk
{
impl
OutputAsset
for
EcmascriptBuildNodeChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
let
ident
=
self
.chunk
.ident
()
.with_modifier
(
modifier
());
let
ident
=
self
.chunk
.ident
()
.with_modifier
(
modifier
());
AssetIdent
::
from_path
(
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()
))
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
(
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -137,7 +137,7 @@ impl Introspectable for EcmascriptBuildNodeChunk {
...
@@ -137,7 +137,7 @@ impl Introspectable for EcmascriptBuildNodeChunk {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
fn
title
(
self
:
Vc
<
Self
>
)
->
Vc
<
RcStr
>
{
self
.
ident
()
.to_string
()
self
.
path
()
.to_string
()
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-nodejs/src/ecmascript/node/content.rs
View file @
64f34a0e
...
@@ -76,7 +76,7 @@ impl EcmascriptBuildNodeChunkContent {
...
@@ -76,7 +76,7 @@ impl EcmascriptBuildNodeChunkContent {
let
source_maps
=
this
let
source_maps
=
this
.chunking_context
.chunking_context
.reference_chunk_source_maps
(
*
ResolvedVc
::
upcast
(
this
.chunk
));
.reference_chunk_source_maps
(
*
ResolvedVc
::
upcast
(
this
.chunk
));
let
chunk_path_vc
=
this
.chunk
.
ident
()
.
path
();
let
chunk_path_vc
=
this
.chunk
.path
();
let
chunk_path
=
chunk_path_vc
.await
?
;
let
chunk_path
=
chunk_path_vc
.await
?
;
let
mut
code
=
CodeBuilder
::
default
();
let
mut
code
=
CodeBuilder
::
default
();
...
@@ -121,7 +121,7 @@ impl EcmascriptBuildNodeChunkContent {
...
@@ -121,7 +121,7 @@ impl EcmascriptBuildNodeChunkContent {
pub
(
crate
)
async
fn
own_version
(
&
self
)
->
Result
<
Vc
<
EcmascriptBuildNodeChunkVersion
>>
{
pub
(
crate
)
async
fn
own_version
(
&
self
)
->
Result
<
Vc
<
EcmascriptBuildNodeChunkVersion
>>
{
Ok
(
EcmascriptBuildNodeChunkVersion
::
new
(
Ok
(
EcmascriptBuildNodeChunkVersion
::
new
(
self
.chunking_context
.output_root
(),
self
.chunking_context
.output_root
(),
self
.chunk
.
ident
()
.
path
(),
self
.chunk
.path
(),
*
self
.content
,
*
self
.content
,
self
.chunking_context.await
?
.minify_type
(),
self
.chunking_context.await
?
.minify_type
(),
))
))
...
...
turbopack/crates/turbopack-nodejs/src/ecmascript/node/entry/chunk.rs
View file @
64f34a0e
...
@@ -9,7 +9,6 @@ use turbopack_core::{
...
@@ -9,7 +9,6 @@ use turbopack_core::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
ChunkItemExt
,
ChunkableModule
,
ChunkingContext
,
EvaluatableAssets
},
chunk
::{
ChunkItemExt
,
ChunkableModule
,
ChunkingContext
,
EvaluatableAssets
},
code_builder
::{
Code
,
CodeBuilder
},
code_builder
::{
Code
,
CodeBuilder
},
ident
::
AssetIdent
,
module_graph
::
ModuleGraph
,
module_graph
::
ModuleGraph
,
output
::{
OutputAsset
,
OutputAssets
},
output
::{
OutputAsset
,
OutputAssets
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
source_map
::{
GenerateSourceMap
,
OptionSourceMap
,
SourceMapAsset
},
...
@@ -59,9 +58,9 @@ impl EcmascriptBuildNodeEntryChunk {
...
@@ -59,9 +58,9 @@ impl EcmascriptBuildNodeEntryChunk {
let
this
=
self
.await
?
;
let
this
=
self
.await
?
;
let
output_root
=
this
.chunking_context
.output_root
()
.await
?
;
let
output_root
=
this
.chunking_context
.output_root
()
.await
?
;
let
chunk_path
=
self
.
ident
()
.
path
()
.await
?
;
let
chunk_path
=
self
.path
()
.await
?
;
let
chunk_directory
=
self
.
ident
()
.
path
()
.parent
()
.await
?
;
let
chunk_directory
=
self
.path
()
.parent
()
.await
?
;
let
runtime_path
=
self
.runtime_chunk
()
.
ident
()
.
path
()
.await
?
;
let
runtime_path
=
self
.runtime_chunk
()
.path
()
.await
?
;
let
runtime_relative_path
=
let
runtime_relative_path
=
if
let
Some
(
path
)
=
chunk_directory
.get_relative_path_to
(
&
runtime_path
)
{
if
let
Some
(
path
)
=
chunk_directory
.get_relative_path_to
(
&
runtime_path
)
{
path
path
...
@@ -96,7 +95,7 @@ impl EcmascriptBuildNodeEntryChunk {
...
@@ -96,7 +95,7 @@ impl EcmascriptBuildNodeEntryChunk {
let
other_chunks
=
this
.other_chunks.await
?
;
let
other_chunks
=
this
.other_chunks.await
?
;
for
other_chunk
in
&*
other_chunks
{
for
other_chunk
in
&*
other_chunks
{
let
other_chunk_path
=
&*
other_chunk
.
ident
()
.
path
()
.await
?
;
let
other_chunk_path
=
&*
other_chunk
.path
()
.await
?
;
if
let
Some
(
other_chunk_public_path
)
=
output_root
.get_path_to
(
other_chunk_path
)
{
if
let
Some
(
other_chunk_public_path
)
=
output_root
.get_path_to
(
other_chunk_path
)
{
writedoc!
(
writedoc!
(
code
,
code
,
...
@@ -174,8 +173,8 @@ fn chunk_reference_description() -> Vc<RcStr> {
...
@@ -174,8 +173,8 @@ fn chunk_reference_description() -> Vc<RcStr> {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptBuildNodeEntryChunk
{
impl
OutputAsset
for
EcmascriptBuildNodeEntryChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.path
)
*
self
.path
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-nodejs/src/ecmascript/node/entry/runtime.rs
View file @
64f34a0e
...
@@ -4,7 +4,7 @@ use anyhow::{bail, Result};
...
@@ -4,7 +4,7 @@ use anyhow::{bail, Result};
use
indoc
::
writedoc
;
use
indoc
::
writedoc
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::{
File
,
FileSystem
};
use
turbo_tasks_fs
::{
File
,
FileSystem
,
FileSystemPath
};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::
ChunkingContext
,
chunk
::
ChunkingContext
,
...
@@ -41,7 +41,7 @@ impl EcmascriptBuildNodeRuntimeChunk {
...
@@ -41,7 +41,7 @@ impl EcmascriptBuildNodeRuntimeChunk {
let
generate_source_map
=
this
let
generate_source_map
=
this
.chunking_context
.chunking_context
.reference_chunk_source_maps
(
Vc
::
upcast
(
self
));
.reference_chunk_source_maps
(
Vc
::
upcast
(
self
));
let
runtime_path
=
self
.
ident
()
.
path
()
.await
?
;
let
runtime_path
=
self
.path
()
.await
?
;
let
runtime_public_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
runtime_path
)
{
let
runtime_public_path
=
if
let
Some
(
path
)
=
output_root
.get_path_to
(
&
runtime_path
)
{
path
path
}
else
{
}
else
{
...
@@ -105,14 +105,14 @@ impl ValueToString for EcmascriptBuildNodeRuntimeChunk {
...
@@ -105,14 +105,14 @@ impl ValueToString for EcmascriptBuildNodeRuntimeChunk {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
EcmascriptBuildNodeRuntimeChunk
{
impl
OutputAsset
for
EcmascriptBuildNodeRuntimeChunk
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
let
ident
=
AssetIdent
::
from_path
(
let
ident
=
AssetIdent
::
from_path
(
turbopack_ecmascript_runtime
::
embed_fs
()
turbopack_ecmascript_runtime
::
embed_fs
()
.root
()
.root
()
.join
(
"runtime.js"
.into
()),
.join
(
"runtime.js"
.into
()),
);
);
AssetIdent
::
from_path
(
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
()
))
self
.chunking_context
.chunk_path
(
ident
,
".js"
.into
(
))
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbopack-static/src/fixed.rs
View file @
64f34a0e
...
@@ -2,7 +2,6 @@ use turbo_tasks::{ResolvedVc, Vc};
...
@@ -2,7 +2,6 @@ use turbo_tasks::{ResolvedVc, Vc};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source
::
Source
,
source
::
Source
,
};
};
...
@@ -33,8 +32,8 @@ impl FixedStaticAsset {
...
@@ -33,8 +32,8 @@ impl FixedStaticAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
FixedStaticAsset
{
impl
OutputAsset
for
FixedStaticAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
AssetIdent
::
from_path
(
*
self
.output_path
)
*
self
.output_path
}
}
}
}
...
...
turbopack/crates/turbopack-static/src/lib.rs
View file @
64f34a0e
...
@@ -171,7 +171,7 @@ impl EcmascriptChunkItem for ModuleChunkItem {
...
@@ -171,7 +171,7 @@ impl EcmascriptChunkItem for ModuleChunkItem {
path
=
StringifyJs
(
path
=
StringifyJs
(
&
self
&
self
.chunking_context
.chunking_context
.asset_url
(
self
.static_asset
.
ident
())
.asset_url
(
self
.static_asset
.
path
())
.await
?
.await
?
)
)
)
)
...
...
turbopack/crates/turbopack-static/src/output_asset.rs
View file @
64f34a0e
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::
FileContent
;
use
turbo_tasks_fs
::
{
FileContent
,
FileSystemPath
}
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::
ChunkingContext
,
chunk
::
ChunkingContext
,
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source
::
Source
,
source
::
Source
,
};
};
...
@@ -31,7 +30,7 @@ impl StaticAsset {
...
@@ -31,7 +30,7 @@ impl StaticAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
StaticAsset
{
impl
OutputAsset
for
StaticAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
ident
(
&
self
)
->
Result
<
Vc
<
AssetIdent
>>
{
async
fn
path
(
&
self
)
->
Result
<
Vc
<
FileSystemPath
>>
{
let
content
=
self
.source
.content
();
let
content
=
self
.source
.content
();
let
content_hash
=
if
let
AssetContent
::
File
(
file
)
=
&*
content
.await
?
{
let
content_hash
=
if
let
AssetContent
::
File
(
file
)
=
&*
content
.await
?
{
if
let
FileContent
::
Content
(
file
)
=
&*
file
.await
?
{
if
let
FileContent
::
Content
(
file
)
=
&*
file
.await
?
{
...
@@ -43,10 +42,9 @@ impl OutputAsset for StaticAsset {
...
@@ -43,10 +42,9 @@ impl OutputAsset for StaticAsset {
anyhow
::
bail!
(
"StaticAsset::path: unsupported file content"
)
anyhow
::
bail!
(
"StaticAsset::path: unsupported file content"
)
};
};
let
content_hash_b16
=
turbo_tasks_hash
::
encode_hex
(
content_hash
);
let
content_hash_b16
=
turbo_tasks_hash
::
encode_hex
(
content_hash
);
let
asset_path
=
self
Ok
(
self
.chunking_context
.chunking_context
.asset_path
(
content_hash_b16
.into
(),
self
.source
.ident
());
.asset_path
(
content_hash_b16
.into
(),
self
.source
.ident
()))
Ok
(
AssetIdent
::
from_path
(
asset_path
))
}
}
}
}
...
...
turbopack/crates/turbopack-tests/tests/snapshot.rs
View file @
64f34a0e
...
@@ -457,11 +457,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
...
@@ -457,11 +457,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
.await
.await
.context
(
format!
(
.context
(
format!
(
"Failed to walk asset {}"
,
"Failed to walk asset {}"
,
asset
asset
.path
()
.to_string
()
.await
.context
(
"to_string failed"
)
?
.ident
()
.to_string
()
.await
.context
(
"to_string failed"
)
?
))
?
;
))
?
;
}
}
...
@@ -478,7 +474,7 @@ async fn walk_asset(
...
@@ -478,7 +474,7 @@ async fn walk_asset(
seen
:
&
mut
FxHashSet
<
Vc
<
FileSystemPath
>>
,
seen
:
&
mut
FxHashSet
<
Vc
<
FileSystemPath
>>
,
queue
:
&
mut
VecDeque
<
ResolvedVc
<
Box
<
dyn
OutputAsset
>>>
,
queue
:
&
mut
VecDeque
<
ResolvedVc
<
Box
<
dyn
OutputAsset
>>>
,
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
path
=
asset
.
ident
()
.
path
()
.resolve
()
.await
?
;
let
path
=
asset
.path
()
.resolve
()
.await
?
;
if
!
seen
.insert
(
path
)
{
if
!
seen
.insert
(
path
)
{
return
Ok
(());
return
Ok
(());
...
...
turbopack/crates/turbopack-wasm/src/output_asset.rs
View file @
64f34a0e
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::
ChunkingContext
,
chunk
::
ChunkingContext
,
ident
::
AssetIdent
,
output
::
OutputAsset
,
output
::
OutputAsset
,
source
::
Source
,
source
::
Source
,
};
};
...
@@ -40,12 +40,9 @@ impl WebAssemblyAsset {
...
@@ -40,12 +40,9 @@ impl WebAssemblyAsset {
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
OutputAsset
for
WebAssemblyAsset
{
impl
OutputAsset
for
WebAssemblyAsset
{
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
ident
(
&
self
)
->
Vc
<
AssetIdent
>
{
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
let
ident
=
self
.source
.ident
()
.with_modifier
(
modifier
());
let
ident
=
self
.source
.ident
()
.with_modifier
(
modifier
());
self
.chunking_context
.chunk_path
(
ident
,
".wasm"
.into
())
let
asset_path
=
self
.chunking_context
.chunk_path
(
ident
,
".wasm"
.into
());
AssetIdent
::
from_path
(
asset_path
)
}
}
}
}
...
...
turbopack/crates/turbopack-wasm/src/raw.rs
View file @
64f34a0e
...
@@ -148,7 +148,7 @@ impl EcmascriptChunkItem for RawModuleChunkItem {
...
@@ -148,7 +148,7 @@ impl EcmascriptChunkItem for RawModuleChunkItem {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
content
(
&
self
)
->
Result
<
Vc
<
EcmascriptChunkItemContent
>>
{
async
fn
content
(
&
self
)
->
Result
<
Vc
<
EcmascriptChunkItemContent
>>
{
let
path
=
self
.wasm_asset
.
ident
()
.
path
()
.await
?
;
let
path
=
self
.wasm_asset
.path
()
.await
?
;
let
output_root
=
self
.chunking_context
.output_root
()
.await
?
;
let
output_root
=
self
.chunking_context
.output_root
()
.await
?
;
let
Some
(
path
)
=
output_root
.get_path_to
(
&
path
)
else
{
let
Some
(
path
)
=
output_root
.get_path_to
(
&
path
)
else
{
...
...
turbopack/crates/turbopack/src/lib.rs
View file @
64f34a0e
...
@@ -963,7 +963,7 @@ async fn emit_aggregated_assets(
...
@@ -963,7 +963,7 @@ async fn emit_aggregated_assets(
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
pub
fn
emit_asset
(
asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
)
{
pub
fn
emit_asset
(
asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
)
{
let
_
=
asset
.content
()
.write
(
asset
.
ident
()
.
path
());
let
_
=
asset
.content
()
.write
(
asset
.path
());
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
...
@@ -972,7 +972,7 @@ pub async fn emit_asset_into_dir(
...
@@ -972,7 +972,7 @@ pub async fn emit_asset_into_dir(
output_dir
:
Vc
<
FileSystemPath
>
,
output_dir
:
Vc
<
FileSystemPath
>
,
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
dir
=
&*
output_dir
.await
?
;
let
dir
=
&*
output_dir
.await
?
;
if
asset
.
ident
()
.
path
()
.await
?
.is_inside_ref
(
dir
)
{
if
asset
.path
()
.await
?
.is_inside_ref
(
dir
)
{
let
_
=
emit_asset
(
asset
);
let
_
=
emit_asset
(
asset
);
}
}
Ok
(())
Ok
(())
...
...
turbopack/crates/turbopack/tests/node-file-trace.rs
View file @
64f34a0e
...
@@ -462,7 +462,7 @@ fn node_file_trace<B: Backend + 'static>(
...
@@ -462,7 +462,7 @@ fn node_file_trace<B: Backend + 'static>(
.await
?
;
.await
?
;
#[cfg(not(feature
=
"bench_against_node_nft"
))]
#[cfg(not(feature
=
"bench_against_node_nft"
))]
let
output_path
=
rebased
.
ident
()
.
path
();
let
output_path
=
rebased
.path
();
print_graph
(
ResolvedVc
::
upcast
(
rebased
))
.await
?
;
print_graph
(
ResolvedVc
::
upcast
(
rebased
))
.await
?
;
...
@@ -774,11 +774,11 @@ async fn print_graph(asset: ResolvedVc<Box<dyn OutputAsset>>) -> Result<()> {
...
@@ -774,11 +774,11 @@ async fn print_graph(asset: ResolvedVc<Box<dyn OutputAsset>>) -> Result<()> {
for
&
asset
in
references
.iter
()
.rev
()
{
for
&
asset
in
references
.iter
()
.rev
()
{
queue
.push
((
depth
+
1
,
asset
));
queue
.push
((
depth
+
1
,
asset
));
}
}
println!
(
"{}{}"
,
indent
,
asset
.
ident
()
.to_string
()
.await
?
);
println!
(
"{}{}"
,
indent
,
asset
.
path
()
.to_string
()
.await
?
);
}
else
if
references
.is_empty
()
{
}
else
if
references
.is_empty
()
{
println!
(
"{}{} *"
,
indent
,
asset
.
ident
()
.to_string
()
.await
?
);
println!
(
"{}{} *"
,
indent
,
asset
.
path
()
.to_string
()
.await
?
);
}
else
{
}
else
{
println!
(
"{}{} *..."
,
indent
,
asset
.
ident
()
.to_string
()
.await
?
);
println!
(
"{}{} *..."
,
indent
,
asset
.
path
()
.to_string
()
.await
?
);
}
}
}
}
Ok
(())
Ok
(())
...
...
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