@@ -33,11 +33,15 @@ class HtmlWebpackChildCompiler {
33
33
* @type {Promise<{[templatePath: string]: { content: string, hash: string, entry: WebpackChunk }}> }
34
34
*/
35
35
this . compilationPromise ;
36
-
37
36
/**
38
37
* @type {Date }
39
38
*/
40
39
this . compilationStarted ;
40
+ /**
41
+ * All file dependencies of the child compiler
42
+ * @type {string[] }
43
+ */
44
+ this . fileDependencies = [ ] ;
41
45
}
42
46
43
47
/**
@@ -120,6 +124,10 @@ class HtmlWebpackChildCompiler {
120
124
const compiledTemplates = entries
121
125
? extractHelperFilesFromCompilation ( mainCompilation , childCompilation , outputOptions . filename , entries )
122
126
: [ ] ;
127
+ // Extract file dependencies
128
+ if ( entries ) {
129
+ this . fileDependencies = extractFileDependenciesFilesFromCompilation ( entries ) ;
130
+ }
123
131
// Reject the promise if the childCompilation contains error
124
132
if ( childCompilation && childCompilation . errors && childCompilation . errors . length ) {
125
133
const errorDetails = childCompilation . errors . map ( error => error . message + ( error . error ? ':\n' + error . error : '' ) ) . join ( '\n' ) ;
@@ -181,6 +189,21 @@ function extractHelperFilesFromCompilation (mainCompilation, childCompilation, f
181
189
return helperContents ;
182
190
}
183
191
192
+ /**
193
+ * Return all file dependencies from the given set of entries.
194
+ * @param {WebpackChunk[] } entries
195
+ * @returns {string[] }
196
+ */
197
+ function extractFileDependenciesFilesFromCompilation ( entries ) {
198
+ const fileDependencies = new Map ( ) ;
199
+ entries . forEach ( ( entry ) => {
200
+ entry . entryModule . buildInfo . fileDependencies . forEach ( ( fileDependency ) => {
201
+ fileDependencies . set ( fileDependency , true ) ;
202
+ } ) ;
203
+ } ) ;
204
+ return Array . from ( fileDependencies . keys ( ) ) ;
205
+ }
206
+
184
207
/**
185
208
* @type {WeakMap<WebpackCompiler, HtmlWebpackChildCompiler> }}
186
209
*/
0 commit comments