@@ -34,7 +34,7 @@ import { ChildProcess, ForkOptions, fork } from 'child_process';
3434import * as fs from 'fs' ;
3535import * as path from 'path' ;
3636import * as ts from 'typescript' ;
37- import { Compiler , compilation } from 'webpack' ;
37+ import { Compiler , WebpackFourCompiler , compilation } from 'webpack' ;
3838import { time , timeEnd } from './benchmark' ;
3939import { WebpackCompilerHost } from './compiler_host' ;
4040import { DiagnosticMode , gatherDiagnostics , hasErrors , reportDiagnostics } from './diagnostics' ;
@@ -75,10 +75,6 @@ import {
7575 VirtualFileSystemDecorator ,
7676 VirtualWatchFileSystemDecorator ,
7777} from './virtual_file_system_decorator' ;
78- import {
79- NodeWatchFileSystemInterface ,
80- NormalModuleFactoryRequest ,
81- } from './webpack' ;
8278import { addError , addWarning } from './webpack-diagnostics' ;
8379import { createWebpackInputHost } from './webpack-input-host' ;
8480import { isWebpackFiveOrHigher , mergeResolverMainFields } from './webpack-version' ;
@@ -686,7 +682,10 @@ export class AngularCompilerPlugin {
686682 } ;
687683
688684 // 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+ ) ;
690689
691690 // Anything that remains is unused, because it wasn't referenced directly or transitively
692691 // on the files in the compilation.
@@ -712,7 +711,12 @@ export class AngularCompilerPlugin {
712711
713712 // Registration hook for webpack plugin.
714713 // 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+ } ;
716720 // The below is require by NGCC processor
717721 // since we need to know which fields we need to process
718722 compiler . hooks . environment . tap ( 'angular-compiler' , ( ) => {
@@ -748,13 +752,8 @@ export class AngularCompilerPlugin {
748752 // Decorate inputFileSystem to serve contents of CompilerHost.
749753 // Use decorated inputFileSystem in watchFileSystem.
750754 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-
756755 let host : virtualFs . Host < fs . Stats > = this . _options . host || createWebpackInputHost (
757- compilerWithFileSystems . inputFileSystem ,
756+ compiler . inputFileSystem ,
758757 ) ;
759758
760759 let replacements : Map < Path , Path > | ( ( path : Path ) => Path ) | undefined ;
@@ -791,7 +790,7 @@ export class AngularCompilerPlugin {
791790 this . _errors ,
792791 this . _basePath ,
793792 this . _tsConfigPath ,
794- compilerWithFileSystems . inputFileSystem ,
793+ compiler . inputFileSystem ,
795794 compiler . options . resolve ?. symlinks ,
796795 ) ;
797796
@@ -830,11 +829,11 @@ export class AngularCompilerPlugin {
830829 }
831830
832831 const inputDecorator = new VirtualFileSystemDecorator (
833- compilerWithFileSystems . inputFileSystem ,
832+ compiler . inputFileSystem ,
834833 this . _compilerHost ,
835834 ) ;
836- compilerWithFileSystems . inputFileSystem = inputDecorator ;
837- compilerWithFileSystems . watchFileSystem = new VirtualWatchFileSystemDecorator (
835+ compiler . inputFileSystem = inputDecorator ;
836+ compiler . watchFileSystem = new VirtualWatchFileSystemDecorator (
838837 inputDecorator ,
839838 replacements ,
840839 ) ;
@@ -956,7 +955,7 @@ export class AngularCompilerPlugin {
956955 // when the issuer is a `.ts` or `.ngfactory.js` file.
957956 nmf . hooks . beforeResolve . tapPromise (
958957 'angular-compiler' ,
959- async ( request ?: NormalModuleFactoryRequest ) => {
958+ async ( request ) => {
960959 if ( this . done && request ) {
961960 const name = request . request ;
962961 const issuer = request . contextInfo . issuer ;
0 commit comments