@@ -34,7 +34,7 @@ import { ChildProcess, ForkOptions, fork } from 'child_process';
34
34
import * as fs from 'fs' ;
35
35
import * as path from 'path' ;
36
36
import * as ts from 'typescript' ;
37
- import { Compiler , compilation } from 'webpack' ;
37
+ import { Compiler , WebpackFourCompiler , compilation } from 'webpack' ;
38
38
import { time , timeEnd } from './benchmark' ;
39
39
import { WebpackCompilerHost } from './compiler_host' ;
40
40
import { DiagnosticMode , gatherDiagnostics , hasErrors , reportDiagnostics } from './diagnostics' ;
@@ -75,10 +75,6 @@ import {
75
75
VirtualFileSystemDecorator ,
76
76
VirtualWatchFileSystemDecorator ,
77
77
} from './virtual_file_system_decorator' ;
78
- import {
79
- NodeWatchFileSystemInterface ,
80
- NormalModuleFactoryRequest ,
81
- } from './webpack' ;
82
78
import { addError , addWarning } from './webpack-diagnostics' ;
83
79
import { createWebpackInputHost } from './webpack-input-host' ;
84
80
import { isWebpackFiveOrHigher , mergeResolverMainFields } from './webpack-version' ;
@@ -686,7 +682,10 @@ export class AngularCompilerPlugin {
686
682
} ;
687
683
688
684
// Go over all the modules in the webpack compilation and remove them from the sets.
689
- compilation . modules . forEach ( m => m . resource ? removeSourceFile ( m . resource , true ) : null ) ;
685
+ // tslint:disable-next-line: no-any
686
+ compilation . modules . forEach ( ( m : compilation . Module & { resource ?: string } ) =>
687
+ m . resource ? removeSourceFile ( m . resource , true ) : null ,
688
+ ) ;
690
689
691
690
// Anything that remains is unused, because it wasn't referenced directly or transitively
692
691
// on the files in the compilation.
@@ -712,7 +711,12 @@ export class AngularCompilerPlugin {
712
711
713
712
// Registration hook for webpack plugin.
714
713
// tslint:disable-next-line:no-big-function
715
- apply ( compiler : Compiler & { watchMode ?: boolean , parentCompilation ?: compilation . Compilation } ) {
714
+ apply ( webpackCompiler : Compiler | WebpackFourCompiler ) {
715
+ const compiler = webpackCompiler as Compiler & {
716
+ watchMode ?: boolean ;
717
+ parentCompilation ?: compilation . Compilation ;
718
+ watchFileSystem ?: unknown ;
719
+ } ;
716
720
// The below is require by NGCC processor
717
721
// since we need to know which fields we need to process
718
722
compiler . hooks . environment . tap ( 'angular-compiler' , ( ) => {
@@ -748,13 +752,8 @@ export class AngularCompilerPlugin {
748
752
// Decorate inputFileSystem to serve contents of CompilerHost.
749
753
// Use decorated inputFileSystem in watchFileSystem.
750
754
compiler . hooks . environment . tap ( 'angular-compiler' , ( ) => {
751
- // The webpack types currently do not include these
752
- const compilerWithFileSystems = compiler as Compiler & {
753
- watchFileSystem : NodeWatchFileSystemInterface ,
754
- } ;
755
-
756
755
let host : virtualFs . Host < fs . Stats > = this . _options . host || createWebpackInputHost (
757
- compilerWithFileSystems . inputFileSystem ,
756
+ compiler . inputFileSystem ,
758
757
) ;
759
758
760
759
let replacements : Map < Path , Path > | ( ( path : Path ) => Path ) | undefined ;
@@ -791,7 +790,7 @@ export class AngularCompilerPlugin {
791
790
this . _errors ,
792
791
this . _basePath ,
793
792
this . _tsConfigPath ,
794
- compilerWithFileSystems . inputFileSystem ,
793
+ compiler . inputFileSystem ,
795
794
compiler . options . resolve ?. symlinks ,
796
795
) ;
797
796
@@ -830,11 +829,11 @@ export class AngularCompilerPlugin {
830
829
}
831
830
832
831
const inputDecorator = new VirtualFileSystemDecorator (
833
- compilerWithFileSystems . inputFileSystem ,
832
+ compiler . inputFileSystem ,
834
833
this . _compilerHost ,
835
834
) ;
836
- compilerWithFileSystems . inputFileSystem = inputDecorator ;
837
- compilerWithFileSystems . watchFileSystem = new VirtualWatchFileSystemDecorator (
835
+ compiler . inputFileSystem = inputDecorator ;
836
+ compiler . watchFileSystem = new VirtualWatchFileSystemDecorator (
838
837
inputDecorator ,
839
838
replacements ,
840
839
) ;
@@ -956,7 +955,7 @@ export class AngularCompilerPlugin {
956
955
// when the issuer is a `.ts` or `.ngfactory.js` file.
957
956
nmf . hooks . beforeResolve . tapPromise (
958
957
'angular-compiler' ,
959
- async ( request ?: NormalModuleFactoryRequest ) => {
958
+ async ( request ) => {
960
959
if ( this . done && request ) {
961
960
const name = request . request ;
962
961
const issuer = request . contextInfo . issuer ;
0 commit comments