@@ -170,26 +170,29 @@ export default class ReactFlightWebpackPlugin {
170170
171171 compiler . hooks . emit . tap ( PLUGIN_NAME , compilation => {
172172 const json = { } ;
173- compilation . chunks . forEach ( chunk => {
174- chunk . getModules ( ) . forEach ( mod => {
175- // TOOD: Hook into deps instead of the target module.
176- // That way we know by the type of dep whether to include.
177- // It also resolves conflicts when the same module is in multiple chunks.
178- if ( ! / \. c l i e n t \. j s $ / . test ( mod . resource ) ) {
179- return ;
180- }
181- const moduleExports = { } ;
182- [ '' , '*' ] . concat ( mod . buildMeta . providedExports ) . forEach ( name => {
183- moduleExports [ name ] = {
184- id : mod . id ,
185- chunks : chunk . ids ,
186- name : name ,
187- } ;
173+ compilation . chunkGroups . forEach ( chunkGroup => {
174+ const chunkIds = chunkGroup . chunks . map ( c => c . id ) ;
175+ chunkGroup . chunks . forEach ( chunk => {
176+ 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 ;
194+ }
188195 } ) ;
189- const href = pathToFileURL ( mod . resource ) . href ;
190- if ( href !== undefined ) {
191- json [ href ] = moduleExports ;
192- }
193196 } ) ;
194197 } ) ;
195198 const output = JSON . stringify ( json , null , 2 ) ;
0 commit comments