From 28e33602ba6badd98508dd86098a0ad7e1d0ed9f Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Sat, 24 Jun 2017 01:04:42 -0500 Subject: [PATCH] refactor: Replace usage of chunk.modules 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 --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 6105992e..4222e953 100644 --- a/src/index.js +++ b/src/index.js @@ -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); }); @@ -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); @@ -144,7 +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)); - 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); @@ -181,7 +181,7 @@ class ExtractTextPlugin { }, this); extractedChunks.forEach((extractedChunk) => { if (!isInitialOrHasNoParents(extractedChunk)) { - extractedChunk.modules.slice().forEach((module) => { + extractedChunk.forEachModule((module) => { extractedChunk.removeModule(module); }); } @@ -192,7 +192,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()));