diff options
Diffstat (limited to 'node_modules/webpack/lib/Compilation.js')
-rw-r--r-- | node_modules/webpack/lib/Compilation.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/node_modules/webpack/lib/Compilation.js b/node_modules/webpack/lib/Compilation.js index 72b195745..05f5be60d 100644 --- a/node_modules/webpack/lib/Compilation.js +++ b/node_modules/webpack/lib/Compilation.js @@ -20,9 +20,11 @@ const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate"); const ModuleTemplate = require("./ModuleTemplate");
const Dependency = require("./Dependency");
const ChunkRenderError = require("./ChunkRenderError");
+const AsyncDependencyToInitialChunkWarning = require("./AsyncDependencyToInitialChunkWarning");
const CachedSource = require("webpack-sources").CachedSource;
const Stats = require("./Stats");
const Semaphore = require("./util/Semaphore");
+const Queue = require("./util/Queue");
function byId(a, b) {
if(a.id < b.id) return -1;
@@ -884,12 +886,19 @@ class Compilation extends Tapable { // but only once (blockChunks map)
let c = blockChunks.get(b);
if(c === undefined) {
- c = this.addChunk(b.chunkName, b.module, b.loc);
- blockChunks.set(b, c);
- allCreatedChunks.add(c);
- // We initialize the chunks property
- // this is later filled with the chunk when needed
- b.chunks = [];
+ c = this.namedChunks[b.chunkName];
+ if(c && c.isInitial()) {
+ // TODO webpack 4: convert this to an error
+ this.warnings.push(new AsyncDependencyToInitialChunkWarning(b.chunkName, b.module, b.loc));
+ c = chunk;
+ } else {
+ c = this.addChunk(b.chunkName, b.module, b.loc);
+ blockChunks.set(b, c);
+ allCreatedChunks.add(c);
+ // We initialize the chunks property
+ // this is later filled with the chunk when needed
+ b.chunks = [];
+ }
}
// 2. We store the Block+Chunk mapping as dependency for the chunk
@@ -954,10 +963,10 @@ class Compilation extends Tapable { let availableModules;
let newAvailableModules;
- const queue2 = inputChunks.map(chunk => ({
+ const queue2 = new Queue(inputChunks.map(chunk => ({
chunk,
availableModules: new Set()
- }));
+ })));
// Helper function to check if all modules of a chunk are available
const areModulesAvailable = (chunk, availableModules) => {
@@ -982,7 +991,7 @@ class Compilation extends Tapable { // Iterative traversing of the basic chunk graph
while(queue2.length) {
- const queueItem = queue2.pop();
+ const queueItem = queue2.dequeue();
chunk = queueItem.chunk;
availableModules = queueItem.availableModules;
@@ -1003,6 +1012,7 @@ class Compilation extends Tapable { }
if(!deletedModules)
continue;
+ availableModules = minAvailableModules;
}
// 2. Get the edges at this point of the graph
@@ -1040,7 +1050,7 @@ class Compilation extends Tapable { // 8. Enqueue further traversal
for(const nextChunk of nextChunks) {
- queue2.push({
+ queue2.enqueue({
chunk: nextChunk,
availableModules: newAvailableModules
});
@@ -1415,7 +1425,7 @@ class Compilation extends Tapable { }
createChildCompiler(name, outputOptions, plugins) {
- var idx = (this.childrenCounters[name] || 0);
+ const idx = (this.childrenCounters[name] || 0);
this.childrenCounters[name] = idx + 1;
return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins);
}
|