From 7564bdf6cba4a2b3e87d8bc2d274717a62452f1a Mon Sep 17 00:00:00 2001 From: Jarand Millett Date: Mon, 13 Aug 2018 17:06:01 +0200 Subject: [PATCH 1/4] Fix sorting of undefined moduleIndex --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b266b331..73e3ebfd 100644 --- a/src/index.js +++ b/src/index.js @@ -387,10 +387,12 @@ class MiniCssExtractPlugin { // with different order this can lead to wrong order // but it's not possible to create a correct order in // this case. Don't share chunks if you don't like it. + + const [chunkGroup] = chunk.groupsIterable; if (typeof chunkGroup.getModuleIndex2 === 'function') { modules.sort( - (a, b) => chunkGroup.getModuleIndex2(a) - chunkGroup.getModuleIndex2(b) + (a, b) => (chunkGroup.getModuleIndex2(a) || 0) < (chunkGroup.getModuleIndex2(b) || 0) ? 1 : -1 ); } else { // fallback for older webpack versions From 78b8dd9b8eabeccab8dba6cbf30620d69ea0b0ca Mon Sep 17 00:00:00 2001 From: Jarand Millett Date: Mon, 13 Aug 2018 17:07:05 +0200 Subject: [PATCH 2/4] Remove unwanted changes --- src/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.js b/src/index.js index 73e3ebfd..672cf8c6 100644 --- a/src/index.js +++ b/src/index.js @@ -387,8 +387,6 @@ class MiniCssExtractPlugin { // with different order this can lead to wrong order // but it's not possible to create a correct order in // this case. Don't share chunks if you don't like it. - - const [chunkGroup] = chunk.groupsIterable; if (typeof chunkGroup.getModuleIndex2 === 'function') { modules.sort( From 8e48ba89b0e5fb4d96fb36324fbef3010f353d1b Mon Sep 17 00:00:00 2001 From: Jarand Millett Date: Mon, 13 Aug 2018 17:23:34 +0200 Subject: [PATCH 3/4] fix: linting --- src/index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 672cf8c6..72ba0bdd 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,10 @@ import webpack from 'webpack'; import sources from 'webpack-sources'; const { ConcatSource, SourceMapSource, OriginalSource } = sources; -const { Template, util: { createHash } } = webpack; +const { + Template, + util: { createHash }, +} = webpack; const NS = path.dirname(fs.realpathSync(__filename)); @@ -97,7 +100,12 @@ class CssModule extends webpack.Module { } class CssModuleFactory { - create({ dependencies: [dependency] }, callback) { + create( + { + dependencies: [dependency], + }, + callback + ) { callback(null, new CssModule(dependency)); } } @@ -390,7 +398,11 @@ class MiniCssExtractPlugin { const [chunkGroup] = chunk.groupsIterable; if (typeof chunkGroup.getModuleIndex2 === 'function') { modules.sort( - (a, b) => (chunkGroup.getModuleIndex2(a) || 0) < (chunkGroup.getModuleIndex2(b) || 0) ? 1 : -1 + (a, b) => + (chunkGroup.getModuleIndex2(a) || 0) < + (chunkGroup.getModuleIndex2(b) || 0) + ? 1 + : -1 ); } else { // fallback for older webpack versions From cf07a43d49ca1a9c17711b54a5acd9abb0ecda8f Mon Sep 17 00:00:00 2001 From: Jarand Millett Date: Mon, 13 Aug 2018 17:29:34 +0200 Subject: [PATCH 4/4] fix: revert unwanted changes