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

Commit

Permalink
fix: corrected order for chunk.modules (#563)
Browse files Browse the repository at this point in the history
* corrected order for chunk.modules loop

* added regression test for #548

* upgraded to latest webpack version 3.1.0 which includes needed Chunk.sortModules method

* applied change to new location of index.js
  • Loading branch information
hulkish authored and joshwiens committed Jul 7, 2017
1 parent 10721f5 commit 5a23fc0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"node": ">= 4.3 < 5.0.0 || >= 5.10"
},
"peerDependencies": {
"webpack": "^3.0.0"
"webpack": "^3.1.0"
},
"homepage": "http://github.com/webpack-contrib/extract-text-webpack-plugin",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class ExtractTextPlugin {
async.forEach(chunks, (chunk, callback) => { // eslint-disable-line no-shadow
const extractedChunk = extractedChunks[chunks.indexOf(chunk)];
const shouldExtract = !!(options.allChunks || isInitialOrHasNoParents(chunk));
chunk.sortModules();
async.forEach(chunk.mapModules((c) => { return c; }), (module, callback) => { // eslint-disable-line no-shadow, arrow-body-style
let meta = module[NS];
if (meta && (!meta.options.id || meta.options.id === id)) {
Expand Down
1 change: 1 addition & 0 deletions test/cases/chunk-modules-ordered-by-id/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./c.txt');
3 changes: 3 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.block {
color: tomato;
}
3 changes: 3 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.App {
color: black;
}
6 changes: 6 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/expected/file.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.block {
color: tomato;
}
.App {
color: black;
}
2 changes: 2 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('./a');
require('./b.txt');
7 changes: 7 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var ExtractTextPlugin = require("../../../");
module.exports = {
entry: "./index",
plugins: [
new ExtractTextPlugin("file.css")
]
};

0 comments on commit 5a23fc0

Please sign in to comment.