Skip to content

Commit 4bc428c

Browse files
committed
1 parent 0854c44 commit 4bc428c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ExtractTextPlugin {
143143
});
144144
async.forEach(chunks, (chunk, callback) => { // eslint-disable-line no-shadow
145145
const extractedChunk = extractedChunks[chunks.indexOf(chunk)];
146-
const shouldExtract = !!(options.allChunks || isInitialOrHasNoParents(chunk));
146+
const shouldExtract = !!(options.allChunks);
147147
chunk.sortModules();
148148
async.forEach(chunk.mapModules(c => c), (module, callback) => { // eslint-disable-line no-shadow
149149
let meta = module[NS];
@@ -152,7 +152,16 @@ class ExtractTextPlugin {
152152
// A stricter `shouldExtract !== wasExtracted` check to guard against cases where a previously extracted
153153
// module would be extracted twice. Happens when a module is a dependency of an initial and a non-initial
154154
// chunk. See issue #604
155-
if (shouldExtract && !wasExtracted) {
155+
156+
let cks = module.chunks;
157+
// check every module's chunks.parents() to decide extract or not
158+
for (let i = 0 ; i < cks.length ; i++) {
159+
if (!isInitialOrHasNoParents(cks[i]) && !module.noExtracted) {
160+
module.noExtracted = 1;
161+
break;
162+
}
163+
}
164+
if (shouldExtract || (!module.noExtracted && !wasExtracted)) {
156165
module[`${NS}/extract`] = shouldExtract; // eslint-disable-line no-path-concat
157166
compilation.rebuildModule(module, (err) => {
158167
if (err) {

0 commit comments

Comments
 (0)