Skip to content

Commit d42d52b

Browse files
committed
use specification order for chunks
fixes #webpack#2998
1 parent 61972f4 commit d42d52b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

lib/Compilation.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ Compilation.prototype._addModuleChain = function process(context, dependency, on
427427
};
428428

429429
Compilation.prototype.addEntry = function process(context, entry, name, callback) {
430+
var slot = {
431+
name: name,
432+
module: null
433+
};
434+
this.preparedChunks.push(slot);
430435
this._addModuleChain(context, entry, function(module) {
431436

432437
entry.module = module;
@@ -439,10 +444,10 @@ Compilation.prototype.addEntry = function process(context, entry, name, callback
439444
}
440445

441446
if(module) {
442-
this.preparedChunks.push({
443-
name: name,
444-
module: module
445-
});
447+
slot.module = module;
448+
} else {
449+
var idx = this.preparedChunks.indexOf(slot);
450+
this.preparedChunks.splice(idx, 1);
446451
}
447452
return callback();
448453
}.bind(this));
@@ -514,11 +519,6 @@ Compilation.prototype.unseal = function unseal() {
514519

515520
Compilation.prototype.seal = function seal(callback) {
516521
this.applyPlugins("seal");
517-
this.preparedChunks.sort(function(a, b) {
518-
if(a.name < b.name) return -1;
519-
if(a.name > b.name) return 1;
520-
return 0;
521-
});
522522
this.nextFreeModuleIndex = 0;
523523
this.nextFreeModuleIndex2 = 0;
524524
this.preparedChunks.forEach(function(preparedChunk) {

0 commit comments

Comments
 (0)