@@ -221,33 +221,25 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
221
221
return args ;
222
222
}
223
223
224
- private getUpdatedEmittedFiles ( emittedFiles : string [ ] , chunkFiles : string [ ] ) {
225
- let fallbackFiles : string [ ] = [ ] ;
224
+ private getUpdatedEmittedFiles ( allEmittedFiles : string [ ] , chunkFiles : string [ ] ) {
225
+ const hotHash = this . getCurrentHotUpdateHash ( allEmittedFiles ) ;
226
+ const emittedHotUpdateFiles = _ . difference ( allEmittedFiles , chunkFiles ) ;
227
+
228
+ return { emittedFiles : emittedHotUpdateFiles , fallbackFiles : chunkFiles , hash : hotHash } ;
229
+ }
230
+
231
+ private getCurrentHotUpdateHash ( emittedFiles : string [ ] ) {
226
232
let hotHash ;
227
- let result = emittedFiles . slice ( ) ;
228
233
const hotUpdateScripts = emittedFiles . filter ( x => x . endsWith ( '.hot-update.js' ) ) ;
229
- if ( chunkFiles && chunkFiles . length ) {
230
- result = result . filter ( file => chunkFiles . indexOf ( file ) === - 1 ) ;
234
+ if ( hotUpdateScripts && hotUpdateScripts . length ) {
235
+ // the hash is the same for each hot update in the current compilation
236
+ const hotUpdateName = hotUpdateScripts [ 0 ] ;
237
+ const matcher = / ^ ( .+ ) \. ( .+ ) \. h o t - u p d a t e / gm;
238
+ const matches = matcher . exec ( hotUpdateName ) ;
239
+ hotHash = matches [ 2 ] ;
231
240
}
232
- hotUpdateScripts . forEach ( hotUpdateScript => {
233
- const { name, hash } = this . parseHotUpdateChunkName ( hotUpdateScript ) ;
234
- hotHash = hash ;
235
- // remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js
236
- result = result . filter ( file => file !== `${ name } .js` ) ;
237
- } ) ;
238
- // if applying of hot update fails, we must fallback to the full files
239
- fallbackFiles = emittedFiles . filter ( file => hotUpdateScripts . indexOf ( file ) === - 1 ) ;
240
-
241
- return { emittedFiles : result , fallbackFiles, hash : hotHash } ;
242
- }
243
241
244
- private parseHotUpdateChunkName ( name : string ) {
245
- const matcher = / ^ ( .+ ) \. ( .+ ) \. h o t - u p d a t e / gm;
246
- const matches = matcher . exec ( name ) ;
247
- return {
248
- name : matches [ 1 ] || "" ,
249
- hash : matches [ 2 ] || "" ,
250
- } ;
242
+ return hotHash || "" ;
251
243
}
252
244
253
245
private async stopWebpackForPlatform ( platform : string ) {
0 commit comments