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

refactor: Update deprecated chunk.modules functions #553

Merged
merged 2 commits into from Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
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
11 changes: 6 additions & 5 deletions src/index.js
Expand Up @@ -64,7 +64,7 @@ class ExtractTextPlugin {
}, this);
} else if (checkedChunks.indexOf(chunk) < 0) {
checkedChunks.push(chunk);
chunk.modules.slice().forEach((module) => {
chunk.forEachModule((module) => {
intoChunk.addModule(module);
module.addChunk(intoChunk);
});
Expand All @@ -77,7 +77,7 @@ class ExtractTextPlugin {

renderExtractedChunk(chunk) {
const source = new ConcatSource();
chunk.modules.forEach((module) => {
chunk.forEachModule((module) => {
const moduleSource = module.source();
source.add(this.applyAdditionalInformation(moduleSource, module.additionalInformation));
}, this);
Expand Down Expand Up @@ -144,7 +144,8 @@ class ExtractTextPlugin {
async.forEach(chunks, (chunk, callback) => { // eslint-disable-line no-shadow
const extractedChunk = extractedChunks[chunks.indexOf(chunk)];
const shouldExtract = !!(options.allChunks || isInitialOrHasNoParents(chunk));
async.forEach(chunk.mapModules((c) => { return c; }), (module, callback) => { // eslint-disable-line no-shadow, arrow-body-style
chunk.sortModules();
async.forEach(chunk.mapModules(c => c), (module, callback) => { // eslint-disable-line no-shadow
let meta = module[NS];
if (meta && (!meta.options.id || meta.options.id === id)) {
const wasExtracted = Array.isArray(meta.content);
Expand Down Expand Up @@ -181,7 +182,7 @@ class ExtractTextPlugin {
}, this);
extractedChunks.forEach((extractedChunk) => {
if (!isInitialOrHasNoParents(extractedChunk)) {
extractedChunk.modules.slice().forEach((module) => {
extractedChunk.forEachModule((module) => {
extractedChunk.removeModule(module);
});
}
Expand All @@ -192,7 +193,7 @@ class ExtractTextPlugin {
});
compilation.plugin('additional-assets', (callback) => {
extractedChunks.forEach((extractedChunk) => {
if (extractedChunk.modules.length) {
if (extractedChunk.getNumberOfModules()) {
extractedChunk.modules.sort((a, b) => {
if (!options.ignoreOrder && isInvalidOrder(a, b)) {
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule()));
Expand Down
1 change: 1 addition & 0 deletions test/cases/chunk-modules-ordered-by-id/a.js
@@ -0,0 +1 @@
require('./c.txt');
3 changes: 3 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/b.txt
@@ -0,0 +1,3 @@
.block {
color: tomato;
}
3 changes: 3 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/c.txt
@@ -0,0 +1,3 @@
.App {
color: black;
}
6 changes: 6 additions & 0 deletions test/cases/chunk-modules-ordered-by-id/expected/file.css
@@ -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
@@ -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
@@ -0,0 +1,7 @@
var ExtractTextPlugin = require("../../../");
module.exports = {
entry: "./index",
plugins: [
new ExtractTextPlugin("file.css")
]
};