@@ -8,7 +8,7 @@ use turbo_tasks_fs::FileContent;
88use turbopack_core:: {
99 asset:: AssetContent ,
1010 chunk:: { ChunkingContext , ModuleId } ,
11- code_builder:: { Code , ComposedCode , ComposedCodeBuilder } ,
11+ code_builder:: { Code , CodeComposition , CodeCompositionBuilder , ComposedCode } ,
1212 output:: OutputAsset ,
1313 source_map:: { GenerateSourceMap , SourceMapAsset } ,
1414 version:: { MergeableVersionedContent , Version , VersionedContent , VersionedContentMerger } ,
@@ -62,9 +62,27 @@ impl EcmascriptBrowserChunkContent {
6262 Ok ( self . composed_code ( ) . await ?. code ( ) )
6363 }
6464
65- /// The chunk's code, composed from its chunk items' cells (see [`ComposedCode`] ).
65+ /// The chunk's code, built from its [`composition`](Self::composition ).
6666 #[ turbo_tasks:: function]
6767 async fn composed_code ( self : Vc < Self > ) -> Result < Vc < ComposedCode > > {
68+ let this = self . await ?;
69+ let source_maps = * this
70+ . chunking_context
71+ . reference_chunk_source_maps ( * ResolvedVc :: upcast ( this. chunk ) )
72+ . await ?;
73+ let minification =
74+ ChunkMinification :: for_chunking_context ( Vc :: upcast ( * this. chunking_context ) ) . await ?;
75+ Ok ( minification
76+ . finish_composition ( self . composition ( ) . to_resolved ( ) . await ?, source_maps)
77+ . await ?
78+ . cell ( ) )
79+ }
80+
81+ /// The chunk's structure: its scaffolding, and references to its chunk items' cells (see
82+ /// [`CodeComposition`]). Doesn't read the chunk items' bytes, so it isn't recomputed (and its
83+ /// persisted body isn't rewritten) when only those change.
84+ #[ turbo_tasks:: function]
85+ async fn composition ( self : Vc < Self > ) -> Result < Vc < CodeComposition > > {
6886 let this = self . await ?;
6987 let source_maps = * this
7088 . chunking_context
@@ -88,7 +106,7 @@ impl EcmascriptBrowserChunkContent {
88106 Either :: Right ( CURRENT_CHUNK_METHOD_DOCUMENT_CURRENT_SCRIPT_EXPR )
89107 }
90108 } ;
91- let mut code = ComposedCodeBuilder :: new (
109+ let mut code = CodeCompositionBuilder :: new (
92110 source_maps,
93111 * this. chunking_context . debug_ids_enabled ( ) . await ?,
94112 ) ;
@@ -142,10 +160,7 @@ impl EcmascriptBrowserChunkContent {
142160 ) ?;
143161 code += "]);" ;
144162
145- let ( code, parts) = code. build ( ) ;
146- Ok ( minification
147- . finish_composed_chunk ( code, parts, source_maps) ?
148- . cell ( ) )
163+ Ok ( code. build ( ) . cell ( ) )
149164 }
150165
151166 #[ turbo_tasks:: function]
0 commit comments