@@ -33,9 +33,51 @@ export class WatchStateLoggerPlugin {
33
33
. keys ( compilation . assets )
34
34
. filter ( assetKey => compilation . assets [ assetKey ] . emitted ) ;
35
35
36
+ const webpackRuntimeFiles = getWebpackRuntimeOnlyFiles ( compilation ) ;
37
+ const entryPointFiles = getEntryPointFiles ( compilation ) ;
38
+
36
39
process . send && process . send ( messages . compilationComplete , error => null ) ;
37
40
// Send emitted files so they can be LiveSynced if need be
38
- process . send && process . send ( { emittedFiles } , error => null ) ;
41
+ process . send && process . send ( { emittedFiles, webpackRuntimeFiles , entryPointFiles } , error => null ) ;
39
42
} ) ;
40
43
}
41
44
}
45
+
46
+ function getWebpackRuntimeOnlyFiles ( compilation ) {
47
+ let runtimeOnlyFiles = [ ] ;
48
+ try {
49
+ runtimeOnlyFiles = [ ] . concat ( ...Array . from < any > ( compilation . entrypoints . values ( ) )
50
+ . map ( entrypoint => entrypoint . runtimeChunk )
51
+ // filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js)
52
+ . filter ( runtimeChunk => ! ! runtimeChunk && runtimeChunk . preventIntegration )
53
+ . map ( runtimeChunk => runtimeChunk . files ) )
54
+ // get only the unique files in case of "single" runtime (e.g. runtime.js)
55
+ . filter ( ( value , index , self ) => self . indexOf ( value ) === index ) ;
56
+ } catch ( e ) {
57
+ // breaking change in the Webpack API
58
+ console . log ( "Warning: Unable to find Webpack runtime files." ) ;
59
+ }
60
+
61
+ return runtimeOnlyFiles ;
62
+ }
63
+
64
+ function getEntryPointFiles ( compilation ) {
65
+ const entryPointFiles = [ ] ;
66
+ try {
67
+ Array . from ( compilation . entrypoints . values ( ) )
68
+ . forEach ( ( entrypoint : any ) => {
69
+ const entryChunk = entrypoint . chunks . find ( chunk => chunk . name === entrypoint . options . name ) ;
70
+ if ( entryChunk ) {
71
+ entryChunk . files . forEach ( fileName => {
72
+ if ( fileName . indexOf ( "hot-update" ) === - 1 ) {
73
+ entryPointFiles . push ( fileName ) ;
74
+ }
75
+ } ) ;
76
+ }
77
+ } ) ;
78
+ } catch ( e ) {
79
+ console . log ( "Warning: Unable to find Webpack entry point files." ) ;
80
+ }
81
+
82
+ return entryPointFiles ;
83
+ }
0 commit comments