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

Commit 1ec14f2

Browse files
committed
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
1 parent 5a23fc0 commit 1ec14f2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ExtractTextPlugin {
6464
}, this);
6565
} else if (checkedChunks.indexOf(chunk) < 0) {
6666
checkedChunks.push(chunk);
67-
chunk.modules.slice().forEach((module) => {
67+
chunk.forEachModule((module) => {
6868
intoChunk.addModule(module);
6969
module.addChunk(intoChunk);
7070
});
@@ -77,7 +77,7 @@ class ExtractTextPlugin {
7777

7878
renderExtractedChunk(chunk) {
7979
const source = new ConcatSource();
80-
chunk.modules.forEach((module) => {
80+
chunk.forEachModule((module) => {
8181
const moduleSource = module.source();
8282
source.add(this.applyAdditionalInformation(moduleSource, module.additionalInformation));
8383
}, this);
@@ -145,7 +145,7 @@ class ExtractTextPlugin {
145145
const extractedChunk = extractedChunks[chunks.indexOf(chunk)];
146146
const shouldExtract = !!(options.allChunks || isInitialOrHasNoParents(chunk));
147147
chunk.sortModules();
148-
async.forEach(chunk.mapModules((c) => { return c; }), (module, callback) => { // eslint-disable-line no-shadow, arrow-body-style
148+
async.forEach(chunk.mapModules(c => c), (module, callback) => { // eslint-disable-line no-shadow
149149
let meta = module[NS];
150150
if (meta && (!meta.options.id || meta.options.id === id)) {
151151
const wasExtracted = Array.isArray(meta.content);
@@ -182,7 +182,7 @@ class ExtractTextPlugin {
182182
}, this);
183183
extractedChunks.forEach((extractedChunk) => {
184184
if (!isInitialOrHasNoParents(extractedChunk)) {
185-
extractedChunk.modules.slice().forEach((module) => {
185+
extractedChunk.forEachModule((module) => {
186186
extractedChunk.removeModule(module);
187187
});
188188
}
@@ -193,7 +193,7 @@ class ExtractTextPlugin {
193193
});
194194
compilation.plugin('additional-assets', (callback) => {
195195
extractedChunks.forEach((extractedChunk) => {
196-
if (extractedChunk.modules.length) {
196+
if (extractedChunk.getNumberOfModules()) {
197197
extractedChunk.modules.sort((a, b) => {
198198
if (!options.ignoreOrder && isInvalidOrder(a, b)) {
199199
compilation.errors.push(new OrderUndefinedError(a.getOriginalModule()));

0 commit comments

Comments
 (0)