File tree Expand file tree Collapse file tree 1 file changed +35
-4
lines changed
Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -383,13 +383,44 @@ Compilation.prototype.applyModuleIds = function applyModuleIds() {
383383} ;
384384
385385Compilation . prototype . applyChunkIds = function applyChunkIds ( ) {
386- var i = 0 ;
386+ var i = this . cache && this . cache [ "nextChunkId" ] || 1 ;
387+ var usedIds = { 0 :true } ;
388+ if ( this . cache ) {
389+ if ( ! this . cache . chunks )
390+ this . cache . chunks = { } ;
391+ var keys = Object . keys ( this . cache . chunks ) . slice ( ) ;
392+ var cacheChunks = this . cache . chunks ;
393+ this . cache . chunks = { } ;
394+ }
387395 this . chunks . forEach ( function ( chunk ) {
388- if ( chunk . id === null )
389- chunk . id = ++ i ;
396+ if ( chunk . id === null ) {
397+ if ( this . cache ) {
398+ for ( var j = 0 ; j < keys . length ; j ++ ) {
399+ var chunkId = keys [ j ] ;
400+ var cacheChunk = cacheChunks [ chunkId ] ;
401+ if ( usedIds [ cacheChunk . id ] ) continue ;
402+ if ( chunk . blocks . some ( function ( block ) {
403+ return cacheChunk . blocks . indexOf ( block ) >= 0 ;
404+ } ) ) {
405+ usedIds [ cacheChunk . id ] = true ;
406+ chunk . id = cacheChunk . id ;
407+ break ;
408+ }
409+ }
410+ }
411+ if ( chunk . id === null )
412+ chunk . id = i ++ ;
413+ if ( this . cache ) {
414+ this . cache . chunks [ "c" + chunk . id ] = {
415+ id : chunk . id ,
416+ blocks : chunk . blocks
417+ } ;
418+ }
419+ }
390420 if ( ! chunk . ids )
391421 chunk . ids = [ chunk . id ] ;
392- } ) ;
422+ } , this ) ;
423+ if ( this . cache ) this . cache [ "nextChunkId" ] = i ;
393424} ;
394425
395426Compilation . prototype . sortItems = function sortItems ( ) {
You can’t perform that action at this time.
0 commit comments