Skip to content

Commit

Permalink
refactor: only output when any chunk is fulfilled (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
laysent authored and evilebottnawi committed Nov 25, 2019
1 parent 357d073 commit c7eda97
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Expand Up @@ -514,8 +514,11 @@ class MiniCssExtractPlugin {
return [
` * ${m.readableIdentifier(requestShortener)}`,
` - couldn't fulfill desired order of chunk group(s) ${failedChunkGroups}`,
` - while fulfilling desired order of chunk group(s) ${goodChunkGroups}`,
].join('\n');
goodChunkGroups &&
` - while fulfilling desired order of chunk group(s) ${goodChunkGroups}`,
]
.filter(Boolean)
.join('\n');
}),
].join('\n')
)
Expand Down
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/e1.css
@@ -0,0 +1,3 @@
body {
content: 'e1';
}
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/e2.css
@@ -0,0 +1,3 @@
body {
content: 'e2';
}
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/e3.css
@@ -0,0 +1,3 @@
body {
content: 'e3';
}
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/e4.css
@@ -0,0 +1,3 @@
body {
content: 'e4';
}
16 changes: 16 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/expected/styles.css
@@ -0,0 +1,16 @@
body {
content: 'e1';
}

body {
content: 'e4';
}

body {
content: 'e2';
}

body {
content: 'e3';
}

1 change: 1 addition & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/index.js
@@ -0,0 +1 @@
import './e1.css';
2 changes: 2 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/index2.js
@@ -0,0 +1,2 @@
import './e2.css';
import './e1.css';
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/index3.js
@@ -0,0 +1,3 @@
import './e3.css';
import './e4.css';
import './e2.css';
3 changes: 3 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/index4.js
@@ -0,0 +1,3 @@
import './e4.css';
import './e2.css';
import './e3.css';
27 changes: 27 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/warnings.js
@@ -0,0 +1,27 @@
const cssLoaderPath = require.resolve('css-loader').replace(/\\/g, '/');

module.exports = [
'',
'WARNING in chunk styles [mini-css-extract-plugin]',
'Conflicting order. Following module has been added:',
` * css ${cssLoaderPath}!./e1.css`,
'despite it was not able to fulfill desired ordering with these modules:',
` * css ${cssLoaderPath}!./e2.css`,
" - couldn't fulfill desired order of chunk group(s) entry2",
'',
'WARNING in chunk styles [mini-css-extract-plugin]',
'Conflicting order. Following module has been added:',
` * css ${cssLoaderPath}!./e4.css`,
'despite it was not able to fulfill desired ordering with these modules:',
` * css ${cssLoaderPath}!./e3.css`,
" - couldn't fulfill desired order of chunk group(s) entry3",
' - while fulfilling desired order of chunk group(s) entry4',
'',
'WARNING in chunk styles [mini-css-extract-plugin]',
'Conflicting order. Following module has been added:',
` * css ${cssLoaderPath}!./e2.css`,
'despite it was not able to fulfill desired ordering with these modules:',
` * css ${cssLoaderPath}!./e3.css`,
" - couldn't fulfill desired order of chunk group(s) entry3",
' - while fulfilling desired order of chunk group(s) entry4',
].join('\n');
35 changes: 35 additions & 0 deletions test/cases/ignoreOrderFalseWithoutGoodChunks/webpack.config.js
@@ -0,0 +1,35 @@
import Self from '../../../src';

module.exports = {
entry: {
entry1: './index.js',
entry2: './index2.js',
entry3: './index3.js',
entry4: './index4.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
chunks: 'all',
test: /\.css$/,
enforce: true,
},
},
},
},
plugins: [
new Self({
ignoreOrder: false,
}),
],
};

0 comments on commit c7eda97

Please sign in to comment.