@@ -152,6 +152,7 @@ class MiniCssExtractPlugin {
152
152
apply ( compiler ) {
153
153
compiler . hooks . thisCompilation . tap ( pluginName , ( compilation ) => {
154
154
const asyncModuleToBeRebuild = new Set ( ) ;
155
+ // eslint-disable-next-line no-param-reassign
155
156
compilation [ MODULE_TYPE ] = {
156
157
asyncModuleToBeRebuild,
157
158
} ;
@@ -450,42 +451,40 @@ class MiniCssExtractPlugin {
450
451
) ;
451
452
452
453
const len = `// extracted by ${ pluginName } ` . length ;
453
- mainTemplate . hooks . beforeStartup . tap (
454
- pluginName ,
455
- ( source , chunk , hash ) => {
456
- for ( const _m of asyncModuleToBeRebuild ) {
457
- const issuerDeps = _m . issuer . dependencies ;
458
- let firstIndex = - 1 ;
459
- const content = [ ] ;
460
-
461
- for ( let i = issuerDeps . length - 1 ; i >= 0 ; i -- ) {
462
- const { module} = issuerDeps [ i ] ;
463
- if ( asyncModuleToBeRebuild . has ( module ) ) {
464
- firstIndex = i ;
465
- content . push ( module . content . replace ( / (?: [ \r \n ] + ) / g, '\\n' ) ) ;
466
- issuerDeps . splice ( i , 1 ) ;
467
- }
454
+ mainTemplate . hooks . beforeStartup . tap ( pluginName , ( source ) => {
455
+ for ( const moduleToBeRebuild of asyncModuleToBeRebuild ) {
456
+ const issuerDeps = moduleToBeRebuild . issuer . dependencies ;
457
+ let firstIndex = - 1 ;
458
+ const content = [ ] ;
459
+
460
+ for ( let i = issuerDeps . length - 1 ; i >= 0 ; i -- ) {
461
+ const { module } = issuerDeps [ i ] ;
462
+ if ( asyncModuleToBeRebuild . has ( module ) ) {
463
+ firstIndex = i ;
464
+ content . push ( module . content . replace ( / (?: [ \r \n ] + ) / g, '\\n' ) ) ;
465
+ issuerDeps . splice ( i , 1 ) ;
468
466
}
467
+ }
469
468
470
- if ( firstIndex > - 1 ) {
471
- issuerDeps . splice (
472
- firstIndex ,
469
+ if ( firstIndex > - 1 ) {
470
+ issuerDeps . splice (
471
+ firstIndex ,
472
+ 0 ,
473
+ new ReplaceDependency ( `module.exports = "${ content . join ( '' ) } ";` , [
473
474
0 ,
474
- new ReplaceDependency (
475
- `module.exports = "${ content . join ( '' ) } ";` ,
476
- [ 0 , len ]
477
- )
478
- ) ;
479
- }
475
+ len ,
476
+ ] )
477
+ ) ;
480
478
}
481
- return source ;
482
479
}
483
- ) ;
480
+
481
+ return source ;
482
+ } ) ;
484
483
} ) ;
485
484
}
486
485
487
486
shouldDisableAsync ( { module } ) {
488
- const { disableAsync} = this . options ;
487
+ const { disableAsync } = this . options ;
489
488
let shouldDisable = false ;
490
489
if ( disableAsync === true ) {
491
490
shouldDisable = true ;
0 commit comments