1- use std:: io:: Write ;
1+ use std:: { borrow :: Cow , io:: Write } ;
22
33use anyhow:: Result ;
44use byteorder:: { BE , WriteBytesExt } ;
@@ -23,7 +23,7 @@ use turbopack_core::{
2323 reference:: all_assets_from_entries,
2424} ;
2525
26- use crate :: route:: { Endpoint , ModuleGraphs } ;
26+ use crate :: route:: ModuleGraphs ;
2727
2828#[ derive(
2929 Default , Clone , Debug , Deserialize , Eq , NonLocalValue , PartialEq , Serialize , TraceRawVcs ,
@@ -371,9 +371,16 @@ pub async fn analyze_output_assets(output_assets: Vc<OutputAssets>) -> Result<Vc
371371 let output_file_index = builder. add_output_file ( AnalyzeOutputFile { filename } ) ;
372372 let chunk_parts = split_output_asset_into_parts ( * asset) . await ?;
373373 for chunk_part in chunk_parts {
374- let source_index = builder
375- . ensure_source ( chunk_part. source . trim_start_matches ( & prefix) )
376- . 1 ;
374+ let decoded_source = urlencoding:: decode ( & chunk_part. source ) ?;
375+ let source = if let Some ( stripped) = decoded_source. strip_prefix ( & prefix) {
376+ Cow :: Borrowed ( stripped)
377+ } else {
378+ Cow :: Owned ( format ! (
379+ "[project]/{}" ,
380+ decoded_source. trim_start_matches( "../" )
381+ ) )
382+ } ;
383+ let source_index = builder. ensure_source ( & source) . 1 ;
377384 let chunk_part_index = builder. add_chunk_part ( AnalyzeChunkPart {
378385 source_index,
379386 output_file_index,
@@ -533,13 +540,6 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
533540 Ok ( FileContent :: Content ( File :: from ( rope) ) . cell ( ) )
534541}
535542
536- #[ turbo_tasks:: function]
537- pub async fn analyze_endpoint ( endpoint : Vc < Box < dyn Endpoint > > ) -> Result < Vc < FileContent > > {
538- Ok ( analyze_output_assets (
539- * endpoint. output ( ) . await ?. output_assets ,
540- ) )
541- }
542-
543543#[ turbo_tasks:: value]
544544pub struct AnalyzeDataOutputAsset {
545545 pub path : FileSystemPath ,
@@ -549,10 +549,13 @@ pub struct AnalyzeDataOutputAsset {
549549#[ turbo_tasks:: value_impl]
550550impl AnalyzeDataOutputAsset {
551551 #[ turbo_tasks:: function]
552- pub async fn new ( path : FileSystemPath , output_assets : Vc < OutputAssets > ) -> Result < Vc < Self > > {
552+ pub async fn new (
553+ path : FileSystemPath ,
554+ output_assets : ResolvedVc < OutputAssets > ,
555+ ) -> Result < Vc < Self > > {
553556 Ok ( Self {
554557 path,
555- output_assets : output_assets . to_resolved ( ) . await ? ,
558+ output_assets,
556559 }
557560 . cell ( ) )
558561 }
0 commit comments