@@ -28,19 +28,26 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
2828 prepareData . watch = true ;
2929 const childProcess = await this . startWebpackProcess ( platformData , projectData , prepareData ) ;
3030
31- childProcess . on ( "message" , ( message : any ) => {
31+ childProcess . on ( "message" , ( message : string | IWebpackEmitMessage ) => {
3232 if ( message === "Webpack compilation complete." ) {
3333 this . $logger . info ( "Webpack build done!" ) ;
3434 resolve ( childProcess ) ;
3535 }
3636
37+ message = message as IWebpackEmitMessage ;
3738 if ( message . emittedFiles ) {
3839 if ( isFirstWebpackWatchCompilation ) {
3940 isFirstWebpackWatchCompilation = false ;
4041 return ;
4142 }
4243
43- const result = this . getUpdatedEmittedFiles ( message . emittedFiles , message . webpackRuntimeFiles , message . entryPointFiles ) ;
44+ let result ;
45+
46+ if ( prepareData . hmr ) {
47+ result = this . getUpdatedEmittedFiles ( message . emittedFiles , message . webpackRuntimeFiles , message . entryPointFiles ) ;
48+ } else {
49+ result = { emittedFiles : message . emittedFiles , fallbackFiles : < string [ ] > [ ] , hash : "" } ;
50+ }
4451
4552 const files = result . emittedFiles
4653 . map ( ( file : string ) => path . join ( platformData . appDestinationDirectoryPath , "app" , file ) ) ;
@@ -49,13 +56,16 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
4956
5057 const data = {
5158 files,
59+ hasOnlyHotUpdateFiles : files . every ( f => f . indexOf ( "hot-update" ) > - 1 ) ,
5260 hmrData : {
5361 hash : result . hash ,
5462 fallbackFiles
5563 }
5664 } ;
5765
58- this . emit ( WEBPACK_COMPILATION_COMPLETE , data ) ;
66+ if ( data . files . length ) {
67+ this . emit ( WEBPACK_COMPILATION_COMPLETE , data ) ;
68+ }
5969 }
6070 } ) ;
6171
@@ -193,27 +203,24 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
193203 private getUpdatedEmittedFiles ( emittedFiles : string [ ] , webpackRuntimeFiles : string [ ] , entryPointFiles : string [ ] ) {
194204 let fallbackFiles : string [ ] = [ ] ;
195205 let hotHash ;
196- if ( emittedFiles . some ( x => x . endsWith ( '.hot-update.json' ) ) ) {
197- let result = emittedFiles . slice ( ) ;
198- const hotUpdateScripts = emittedFiles . filter ( x => x . endsWith ( '.hot-update.js' ) ) ;
199- if ( webpackRuntimeFiles && webpackRuntimeFiles . length ) {
200- result = result . filter ( file => webpackRuntimeFiles . indexOf ( file ) === - 1 ) ;
201- }
202- if ( entryPointFiles && entryPointFiles . length ) {
203- result = result . filter ( file => entryPointFiles . indexOf ( file ) === - 1 ) ;
204- }
205- hotUpdateScripts . forEach ( hotUpdateScript => {
206- const { name, hash } = this . parseHotUpdateChunkName ( hotUpdateScript ) ;
207- hotHash = hash ;
208- // remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js
209- result = result . filter ( file => file !== `${ name } .js` ) ;
210- } ) ;
211- // if applying of hot update fails, we must fallback to the full files
212- fallbackFiles = emittedFiles . filter ( file => result . indexOf ( file ) === - 1 ) ;
213- return { emittedFiles : result , fallbackFiles, hash : hotHash } ;
206+ let result = emittedFiles . slice ( ) ;
207+ const hotUpdateScripts = emittedFiles . filter ( x => x . endsWith ( '.hot-update.js' ) ) ;
208+ if ( webpackRuntimeFiles && webpackRuntimeFiles . length ) {
209+ result = result . filter ( file => webpackRuntimeFiles . indexOf ( file ) === - 1 ) ;
214210 }
211+ if ( entryPointFiles && entryPointFiles . length ) {
212+ result = result . filter ( file => entryPointFiles . indexOf ( file ) === - 1 ) ;
213+ }
214+ hotUpdateScripts . forEach ( hotUpdateScript => {
215+ const { name, hash } = this . parseHotUpdateChunkName ( hotUpdateScript ) ;
216+ hotHash = hash ;
217+ // remove bundle/vendor.js files if there's a bundle.XXX.hot-update.js or vendor.XXX.hot-update.js
218+ result = result . filter ( file => file !== `${ name } .js` ) ;
219+ } ) ;
220+ // if applying of hot update fails, we must fallback to the full files
221+ fallbackFiles = emittedFiles . filter ( file => hotUpdateScripts . indexOf ( file ) === - 1 ) ;
215222
216- return { emittedFiles, fallbackFiles } ;
223+ return { emittedFiles : result , fallbackFiles, hash : hotHash } ;
217224 }
218225
219226 private parseHotUpdateChunkName ( name : string ) {
0 commit comments