Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 27e3a28

Browse files
committed
fix: Module sorting
1 parent 28363ab commit 27e3a28

File tree

10 files changed

+48
-3
lines changed

10 files changed

+48
-3
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
"presets": [
2828
"env"
2929
],
30+
"sourceMap" : "inline",
3031
"plugins": [
3132
"transform-object-rest-spread"
3233
]
3334
}
3435
}
35-
}
36+
}

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class ExtractTextPlugin {
144144
async.forEach(chunks, (chunk, callback) => { // eslint-disable-line no-shadow
145145
const extractedChunk = extractedChunks[chunks.indexOf(chunk)];
146146
const shouldExtract = !!(options.allChunks || isInitialOrHasNoParents(chunk));
147-
chunk.sortModules();
148147
async.forEach(chunk.mapModules(c => c), (module, callback) => { // eslint-disable-line no-shadow
149148
let meta = module[NS];
150149
if (meta && (!meta.options.id || meta.options.id === id)) {
@@ -194,7 +193,7 @@ class ExtractTextPlugin {
194193
compilation.plugin('additional-assets', (callback) => {
195194
extractedChunks.forEach((extractedChunk) => {
196195
if (extractedChunk.getNumberOfModules()) {
197-
extractedChunk.modules.sort((a, b) => {
196+
extractedChunk.sortModules((a, b) => {
198197
if (!options.ignoreOrder && isInvalidOrder(a, b)) {
199198
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule()));
200199
compilation.errors.push(new OrderUndefinedError(b.getOriginalModule()));

test/__snapshots__/webpack-integration.test.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Webpack Integration Tests chunk-modules-css-wrong-order 1`] = `
4+
".block {
5+
font-size: 16px;
6+
}
7+
.App {
8+
text-align: center;
9+
}
10+
"
11+
`;
12+
313
exports[`Webpack Integration Tests chunk-modules-nested-ordered-by-id 1`] = `
414
"body {
515
margin: 0;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.App {
2+
text-align: center;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('./b.js');
2+
require('./a.css');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.block {
2+
font-size: 16px;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./b.css');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.block {
2+
font-size: 16px;
3+
}
4+
.App {
5+
text-align: center;
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./a.js');
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import ExtractTextPlugin from '../../../src/index';
2+
3+
module.exports = {
4+
entry: './index',
5+
module: {
6+
loaders: [
7+
{
8+
test: /\.css$/,
9+
use: ExtractTextPlugin.extract({
10+
fallback: { loader: 'style-loader' },
11+
use: { loader: 'css-loader', },
12+
})
13+
},
14+
],
15+
},
16+
plugins: [
17+
new ExtractTextPlugin('file.css'),
18+
],
19+
};

0 commit comments

Comments
 (0)