@@ -20,8 +20,6 @@ const {
2020 util : { createHash } ,
2121} = webpack ;
2222
23- const isWebpack4 = webpackVersion [ 0 ] === '4' ;
24-
2523const pluginName = 'mini-css-extract-plugin' ;
2624
2725const REGEXP_CHUNKHASH = / \[ c h u n k h a s h (?: : ( \d + ) ) ? \] / i;
@@ -97,16 +95,12 @@ class MiniCssExtractPlugin {
9795 this . options . chunkFilename = '[id].css' ;
9896 }
9997 }
100-
101- if ( ! isWebpack4 && 'hmr' in this . options ) {
102- throw new Error (
103- "The 'hmr' option doesn't exist for the mini-css-extract-plugin when using webpack 5 (it's automatically determined)"
104- ) ;
105- }
10698 }
10799
108100 /** @param {import("webpack").Compiler } compiler */
109101 apply ( compiler ) {
102+ const isWebpack4 = compiler . webpack ? false : webpackVersion [ 0 ] === '4' ;
103+
110104 if ( ! isWebpack4 ) {
111105 const { splitChunks } = compiler . options . optimization ;
112106 if ( splitChunks ) {
@@ -200,7 +194,9 @@ class MiniCssExtractPlugin {
200194
201195 // We don't need hot update chunks for css
202196 // We will use the real asset instead to update
203- if ( chunk instanceof webpack . HotUpdateChunk ) return ;
197+ if ( chunk instanceof webpack . HotUpdateChunk ) {
198+ return ;
199+ }
204200
205201 const renderedModules = Array . from (
206202 this . getChunkModules ( chunk , chunkGraph )
@@ -439,7 +435,10 @@ class MiniCssExtractPlugin {
439435 } else {
440436 const enabledChunks = new WeakSet ( ) ;
441437 const handler = ( chunk , set ) => {
442- if ( enabledChunks . has ( chunk ) ) return ;
438+ if ( enabledChunks . has ( chunk ) ) {
439+ return ;
440+ }
441+
443442 enabledChunks . add ( chunk ) ;
444443
445444 // eslint-disable-next-line global-require
0 commit comments