@@ -172,25 +172,36 @@ export default class ReactFlightWebpackPlugin {
172172 const json = { } ;
173173 compilation . chunkGroups . forEach ( chunkGroup => {
174174 const chunkIds = chunkGroup . chunks . map ( c => c . id ) ;
175+
176+ function recordModule ( id , mod ) {
177+ // TODO: Hook into deps instead of the target module.
178+ // That way we know by the type of dep whether to include.
179+ // It also resolves conflicts when the same module is in multiple chunks.
180+ if ( ! / \. c l i e n t \. j s $ / . test ( mod . resource ) ) {
181+ return ;
182+ }
183+ const moduleExports = { } ;
184+ [ '' , '*' ] . concat ( mod . buildMeta . providedExports ) . forEach ( name => {
185+ moduleExports [ name ] = {
186+ id : id ,
187+ chunks : chunkIds ,
188+ name : name ,
189+ } ;
190+ } ) ;
191+ const href = pathToFileURL ( mod . resource ) . href ;
192+ if ( href !== undefined ) {
193+ json [ href ] = moduleExports ;
194+ }
195+ }
196+
175197 chunkGroup . chunks . forEach ( chunk => {
176198 chunk . getModules ( ) . forEach ( mod => {
177- // TODO: Hook into deps instead of the target module.
178- // That way we know by the type of dep whether to include.
179- // It also resolves conflicts when the same module is in multiple chunks.
180- if ( ! / \. c l i e n t \. j s $ / . test ( mod . resource ) ) {
181- return ;
182- }
183- const moduleExports = { } ;
184- [ '' , '*' ] . concat ( mod . buildMeta . providedExports ) . forEach ( name => {
185- moduleExports [ name ] = {
186- id : mod . id ,
187- chunks : chunkIds ,
188- name : name ,
189- } ;
190- } ) ;
191- const href = pathToFileURL ( mod . resource ) . href ;
192- if ( href !== undefined ) {
193- json [ href ] = moduleExports ;
199+ recordModule ( mod . id , mod ) ;
200+ // If this is a concatenation, register each child to the parent ID.
201+ if ( mod . modules ) {
202+ mod . modules . forEach ( concatenatedMod => {
203+ recordModule ( mod . id , concatenatedMod ) ;
204+ } ) ;
194205 }
195206 } ) ;
196207 } ) ;
0 commit comments