@@ -20,6 +20,7 @@ const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate");
2020const ModuleTemplate = require ( "./ModuleTemplate" ) ;
2121const Dependency = require ( "./Dependency" ) ;
2222const ChunkRenderError = require ( "./ChunkRenderError" ) ;
23+ const AsyncDependencyToInitialChunkWarning = require ( "./AsyncDependencyToInitialChunkWarning" ) ;
2324const CachedSource = require ( "webpack-sources" ) . CachedSource ;
2425const Stats = require ( "./Stats" ) ;
2526const Semaphore = require ( "./util/Semaphore" ) ;
@@ -885,12 +886,19 @@ class Compilation extends Tapable {
885886 // but only once (blockChunks map)
886887 let c = blockChunks . get ( b ) ;
887888 if ( c === undefined ) {
888- c = this . addChunk ( b . chunkName , b . module , b . loc ) ;
889- blockChunks . set ( b , c ) ;
890- allCreatedChunks . add ( c ) ;
891- // We initialize the chunks property
892- // this is later filled with the chunk when needed
893- b . chunks = [ ] ;
889+ c = this . namedChunks [ b . chunkName ] ;
890+ if ( c && c . isInitial ( ) ) {
891+ // TODO webpack 4: convert this to an error
892+ this . warnings . push ( new AsyncDependencyToInitialChunkWarning ( b . chunkName , b . module , b . loc ) ) ;
893+ c = chunk ;
894+ } else {
895+ c = this . addChunk ( b . chunkName , b . module , b . loc ) ;
896+ blockChunks . set ( b , c ) ;
897+ allCreatedChunks . add ( c ) ;
898+ // We initialize the chunks property
899+ // this is later filled with the chunk when needed
900+ b . chunks = [ ] ;
901+ }
894902 }
895903
896904 // 2. We store the Block+Chunk mapping as dependency for the chunk
0 commit comments