@@ -27,6 +27,7 @@ export class WebpackResourceLoader {
27
27
private _parentCompilation : any ;
28
28
private _context : string ;
29
29
private _fileDependencies = new Map < string , string [ ] > ( ) ;
30
+ private _reverseDependencies = new Map < string , string [ ] > ( ) ;
30
31
private _cachedSources = new Map < string , string > ( ) ;
31
32
private _cachedEvaluatedSources = new Map < string , RawSource > ( ) ;
32
33
@@ -41,6 +42,10 @@ export class WebpackResourceLoader {
41
42
return this . _fileDependencies . get ( filePath ) || [ ] ;
42
43
}
43
44
45
+ getAffectedResources ( file : string ) {
46
+ return this . _reverseDependencies . get ( file ) || [ ] ;
47
+ }
48
+
44
49
private _compile ( filePath : string ) : Promise < CompilationOutput > {
45
50
46
51
if ( ! this . _parentCompilation ) {
@@ -117,6 +122,14 @@ export class WebpackResourceLoader {
117
122
118
123
// Save the dependencies for this resource.
119
124
this . _fileDependencies . set ( filePath , childCompilation . fileDependencies ) ;
125
+ for ( const file of childCompilation . fileDependencies ) {
126
+ const entry = this . _reverseDependencies . get ( file ) ;
127
+ if ( entry ) {
128
+ entry . push ( filePath ) ;
129
+ } else {
130
+ this . _reverseDependencies . set ( file , [ filePath ] ) ;
131
+ }
132
+ }
120
133
121
134
const compilationHash = childCompilation . fullHash ;
122
135
const maybeSource = this . _cachedSources . get ( compilationHash ) ;
0 commit comments