@@ -29,6 +29,7 @@ function Compilation(compiler) {
2929 this . bail = options && options . bail ;
3030 this . profile = options && options . profile ;
3131 this . entries = [ ] ;
32+ this . preparedChunks = [ ] ;
3233 this . chunks = [ ] ;
3334 this . namedChunks = { } ;
3435 this . modules = [ ] ;
@@ -317,18 +318,15 @@ Compilation.prototype.addEntry = function process(context, entry, name, callback
317318 if ( err ) return callback ( err ) ;
318319
319320 if ( module ) {
320- var chunk = this . addChunk ( name ) ;
321- chunk . id = 0 ;
322- chunk . entry = true ;
323- chunk . addModule ( module ) ;
324- module . addChunk ( chunk ) ;
325- this . processDependenciesBlockForChunk ( module , chunk ) ;
321+ this . preparedChunks . push ( {
322+ name : name ,
323+ module : module
324+ } ) ;
326325 }
327326 return callback ( ) ;
328327 } . bind ( this ) ) ;
329328} ;
330329
331-
332330Compilation . prototype . prefetch = function process ( context , dependency , callback ) {
333331 this . _addModuleChain ( context , dependency , function ( module ) {
334332
@@ -339,6 +337,15 @@ Compilation.prototype.prefetch = function process(context, dependency, callback)
339337
340338Compilation . prototype . seal = function seal ( callback ) {
341339 this . applyPlugins ( "seal" ) ;
340+ this . preparedChunks . forEach ( function ( preparedChunk ) {
341+ var module = preparedChunk . module ;
342+ var chunk = this . addChunk ( preparedChunk . name ) ;
343+ chunk . id = 0 ;
344+ chunk . entry = true ;
345+ chunk . addModule ( module ) ;
346+ module . addChunk ( chunk ) ;
347+ this . processDependenciesBlockForChunk ( module , chunk ) ;
348+ } , this ) ;
342349 this . applyPlugins ( "optimize" ) ;
343350 this . applyPlugins ( "optimize-modules" , this . modules ) ;
344351 this . applyPlugins ( "after-optimize-modules" , this . modules ) ;
0 commit comments