@@ -142,15 +142,20 @@ describe('ManifestPlugin using real fs', function() {
142142 } ) ;
143143
144144 describe ( 'watch mode' , function ( ) {
145+ var compiler ;
145146 var hashes ;
146147
147148 beforeAll ( function ( ) {
148149 fse . outputFileSync ( path . join ( __dirname , 'output/watch-mode/index.js' ) , 'console.log(\'v1\')' ) ;
149150 hashes = [ ] ;
150151 } ) ;
151152
153+ afterAll ( ( ) => {
154+ compiler . close ( )
155+ } )
156+
152157 it ( 'outputs a manifest of one file' , function ( done ) {
153- const compiler = webpackCompile ( {
158+ compiler = webpackCompile ( {
154159 context : __dirname ,
155160 output : {
156161 filename : '[name].[hash].js' ,
@@ -174,7 +179,6 @@ describe('ManifestPlugin using real fs', function() {
174179
175180 if ( hashes . length === 2 ) {
176181 expect ( hashes [ 0 ] ) . not . toEqual ( hashes [ 1 ] ) ;
177- compiler . close ( )
178182 return done ( ) ;
179183 }
180184
@@ -183,6 +187,63 @@ describe('ManifestPlugin using real fs', function() {
183187 } ) ;
184188 } ) ;
185189
190+ describe ( 'import() update' , ( ) => {
191+ let compiler ;
192+ let isFirstRun ;
193+
194+ beforeAll ( ( ) => {
195+ fse . outputFileSync ( path . join ( __dirname , 'output/watch-import-chunk/chunk1.js' ) , 'console.log(\'chunk 1\')' ) ;
196+ fse . outputFileSync ( path . join ( __dirname , 'output/watch-import-chunk/chunk2.js' ) , 'console.log(\'chunk 2\')' ) ;
197+ fse . outputFileSync ( path . join ( __dirname , 'output/watch-import-chunk/index.js' ) , 'import(\'./chunk1\')\nimport(\'./chunk2\')' ) ;
198+ isFirstRun = true ;
199+ } ) ;
200+
201+ afterAll ( ( ) => {
202+ compiler . close ( )
203+ } )
204+
205+ it ( 'outputs a manifest of one file' , function ( done ) {
206+ compiler = webpackCompile ( {
207+ context : __dirname ,
208+ output : {
209+ filename : '[name].js' ,
210+ path : path . join ( __dirname , 'output/watch-import-chunk' )
211+ } ,
212+ entry : './output/watch-import-chunk/index.js' ,
213+ watch : true ,
214+ plugins : [
215+ new ManifestPlugin ( ) ,
216+ new webpack . HotModuleReplacementPlugin ( )
217+ ]
218+ } , { } , function ( stats ) {
219+ var manifest = JSON . parse ( fse . readFileSync ( path . join ( __dirname , 'output/watch-import-chunk/manifest.json' ) ) )
220+
221+ expect ( manifest ) . toBeDefined ( ) ;
222+
223+ if ( isFirstRun ) {
224+ expect ( manifest ) . toEqual ( {
225+ 'main.js' : 'main.js' ,
226+ '0.js' : '0.js' ,
227+ '1.js' : '1.js'
228+ } ) ;
229+
230+ isFirstRun = false ;
231+ fse . outputFileSync ( path . join ( __dirname , 'output/watch-import-chunk/index.js' ) , 'import(\'./chunk1\')' ) ;
232+ } else {
233+ expect ( manifest ) . toEqual ( isWebpack4 ( {
234+ 'main.js' : 'main.js' ,
235+ '1.js' : '1.js' ,
236+ } , {
237+ 'main.js' : 'main.js' ,
238+ '3.js' : '3.js' ,
239+ } ) ) ;
240+
241+ done ( ) ;
242+ }
243+ } ) ;
244+ } ) ;
245+ } ) ;
246+
186247 describe ( 'multiple compilation' , function ( ) {
187248 var nbCompiler = 10 ;
188249 var originalTimeout ;
0 commit comments