Skip to content

Commit e016e97

Browse files
authored
Merge pull request webpack#3881 from timse/add-comment-to-sort
add comments to clarify why a sort is needed here.
2 parents a1dca89 + ef59336 commit e016e97

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/Compilation.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,13 @@ class Compilation extends Tapable {
967967
hash.update(child.hash);
968968
});
969969
let chunk;
970+
// clone needed as sort below is inplace mutation
970971
const chunks = this.chunks.slice();
972+
/**
973+
* sort here will bring all "falsy" values to the beginning
974+
* this is needed as the "hasRuntime()" chunks are dependent on the
975+
* hashes of the non-runtime chunks.
976+
*/
971977
chunks.sort((a, b) => {
972978
const aEntry = a.hasRuntime();
973979
const bEntry = b.hasRuntime();

0 commit comments

Comments
 (0)