@@ -31,6 +31,7 @@ export class WatchStateLoggerPlugin {
31
31
console . log ( messages . compilationComplete ) ;
32
32
}
33
33
34
+ const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles ( compilation , compiler ) ;
34
35
let emittedFiles = Object
35
36
. keys ( compilation . assets )
36
37
. filter ( assetKey => compilation . assets [ assetKey ] . emitted ) ;
@@ -42,7 +43,28 @@ export class WatchStateLoggerPlugin {
42
43
43
44
process . send && process . send ( messages . compilationComplete , error => null ) ;
44
45
// Send emitted files so they can be LiveSynced if need be
45
- process . send && process . send ( { emittedFiles : emittedFilesFakePaths } , error => null ) ;
46
+ process . send && process . send ( { emittedFiles : emittedFilesFakePaths , webpackRuntimeFiles : runtimeOnlyFiles } , error => null ) ;
46
47
} ) ;
47
48
}
48
49
}
50
+
51
+ function getWebpackRuntimeOnlyFiles ( compilation , compiler ) {
52
+ let runtimeOnlyFiles = [ ] ;
53
+ try {
54
+ runtimeOnlyFiles = [ ] . concat ( ...compilation . chunkGroups
55
+ // get the chunk group of each entry points (e.g. main.js and inspector-modules.js)
56
+ . map ( chunkGroup => chunkGroup . runtimeChunk )
57
+ // filter embedded runtime chunks (e.g. part of bundle.js or inspector-modules.js)
58
+ . filter ( runtimeChunk => runtimeChunk . preventIntegration )
59
+ . map ( runtimeChunk => runtimeChunk . files ) )
60
+ // get only the unique files in case of "single" runtime (e.g. runtime.js)
61
+ . filter ( ( value , index , self ) => self . indexOf ( value ) === index )
62
+ // convert to absolute paths
63
+ . map ( fileName => join ( compiler . context , fileName ) ) ;
64
+ } catch ( e ) {
65
+ // breaking change in the Webpack API
66
+ console . log ( "Warning: Unable to find Webpack runtime files." ) ;
67
+ }
68
+
69
+ return runtimeOnlyFiles ;
70
+ }
0 commit comments