@@ -142,15 +142,20 @@ describe('ManifestPlugin using real fs', function() {
142
142
} ) ;
143
143
144
144
describe ( 'watch mode' , function ( ) {
145
+ var compiler ;
145
146
var hashes ;
146
147
147
148
beforeAll ( function ( ) {
148
149
fse . outputFileSync ( path . join ( __dirname , 'output/watch-mode/index.js' ) , 'console.log(\'v1\')' ) ;
149
150
hashes = [ ] ;
150
151
} ) ;
151
152
153
+ afterAll ( ( ) => {
154
+ compiler . close ( )
155
+ } )
156
+
152
157
it ( 'outputs a manifest of one file' , function ( done ) {
153
- const compiler = webpackCompile ( {
158
+ compiler = webpackCompile ( {
154
159
context : __dirname ,
155
160
output : {
156
161
filename : '[name].[hash].js' ,
@@ -174,7 +179,6 @@ describe('ManifestPlugin using real fs', function() {
174
179
175
180
if ( hashes . length === 2 ) {
176
181
expect ( hashes [ 0 ] ) . not . toEqual ( hashes [ 1 ] ) ;
177
- compiler . close ( )
178
182
return done ( ) ;
179
183
}
180
184
@@ -183,6 +187,63 @@ describe('ManifestPlugin using real fs', function() {
183
187
} ) ;
184
188
} ) ;
185
189
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
+
186
247
describe ( 'multiple compilation' , function ( ) {
187
248
var nbCompiler = 10 ;
188
249
var originalTimeout ;
0 commit comments