@@ -69,15 +69,15 @@ struct SourceMapJson {
6969 sections : Option < Vec < SourceMapSectionItemJson > > ,
7070}
7171
72- /// Replace the origin prefix in the `sources` with `turbopack:///` and read the the
72+ /// Replace the origin prefix in the `file` and ` sources` with `turbopack:///` and read the the
7373/// `sourceContent`s from disk.
7474pub async fn resolve_source_map_sources (
7575 map : Option < & Rope > ,
7676 origin : Vc < FileSystemPath > ,
7777) -> Result < Option < Rope > > {
7878 async fn resolve_source (
7979 original_source : & mut String ,
80- original_content : & mut Option < String > ,
80+ original_content : Option < & mut Option < String > > ,
8181 origin : Vc < FileSystemPath > ,
8282 ) -> Result < ( ) > {
8383 if let Some ( path) = * origin
@@ -89,7 +89,9 @@ pub async fn resolve_source_map_sources(
8989 let source = format ! ( "{SOURCE_URL_PROTOCOL}///{path_str}" ) ;
9090 * original_source = source;
9191
92- if original_content. is_none ( ) {
92+ if let Some ( original_content) = original_content
93+ && original_content. is_none ( )
94+ {
9395 if let FileContent :: Content ( file) = & * path. read ( ) . await ? {
9496 let text = file. content ( ) . to_str ( ) ?;
9597 * original_content = Some ( text. to_string ( ) )
@@ -105,7 +107,9 @@ pub async fn resolve_source_map_sources(
105107 s[ 0 ] . replace ( '.' , "_" )
106108 } ) ;
107109 * original_source = format ! ( "{SOURCE_URL_PROTOCOL}///{origin_str}/{source}" ) ;
108- if original_content. is_none ( ) {
110+ if let Some ( original_content) = original_content
111+ && original_content. is_none ( )
112+ {
109113 * original_content = Some ( format ! (
110114 "unable to access {original_source} in {origin_str} (it's leaving the \
111115 filesystem root)"
@@ -126,7 +130,7 @@ pub async fn resolve_source_map_sources(
126130
127131 for ( source, content) in sources. iter_mut ( ) . zip ( contents. iter_mut ( ) ) {
128132 if let Some ( source) = source {
129- resolve_source ( source, content, origin) . await ?;
133+ resolve_source ( source, Some ( content) , origin) . await ?;
130134 }
131135 }
132136
@@ -144,6 +148,10 @@ pub async fn resolve_source_map_sources(
144148 return Ok ( None ) ;
145149 } ;
146150
151+ if let Some ( file) = & mut map. file {
152+ resolve_source ( file, None , origin) . await ?;
153+ }
154+
147155 resolve_map ( & mut map, origin) . await ?;
148156 for section in map. sections . iter_mut ( ) . flatten ( ) {
149157 resolve_map ( & mut section. map , origin) . await ?;
0 commit comments