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

Commit

Permalink
refactor: Replace usage of chunk.modules
Browse files Browse the repository at this point in the history
  BREAKING CHANGE: Updates to `Chunk.mapModules | forEachModule | getNumberOfModules`. This release is not backwards compatible with `Webpack 2.x` due to breaking changes in webpack/webpack#4764
  • Loading branch information
joshwiens committed Jul 7, 2017
1 parent 5a23fc0 commit 1ec14f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
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 @@ -145,7 +145,7 @@ class ExtractTextPlugin {
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
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 @@ -182,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 @@ -193,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

0 comments on commit 1ec14f2

Please sign in to comment.