From e83dd931da7a1bb7828bd3326a6c561e50ecfd9b Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Thu, 12 Oct 2017 08:09:19 -0700 Subject: [PATCH] fix(@ngtools/webpack): fix for TypeScript module resolution cache missing in old version --- packages/@ngtools/webpack/src/plugin.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 25525b96dc0d..39bf7b4cdeeb 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -50,7 +50,7 @@ export class AotPlugin implements Tapable { private _compilerOptions: ts.CompilerOptions; private _angularCompilerOptions: any; private _program: ts.Program; - private _moduleResolutionCache: ts.ModuleResolutionCache; + private _moduleResolutionCache?: ts.ModuleResolutionCache; private _rootFilePath: string[]; private _compilerHost: WebpackCompilerHost; private _resourceLoader: WebpackResourceLoader; @@ -225,9 +225,11 @@ export class AotPlugin implements Tapable { this._program = ts.createProgram( this._rootFilePath, this._compilerOptions, this._compilerHost); - // We use absolute paths everywhere. - this._moduleResolutionCache = ts.createModuleResolutionCache( - this._basePath, (fileName: string) => fileName); + if (ts.createModuleResolutionCache) { + // We use absolute paths everywhere. + this._moduleResolutionCache = ts.createModuleResolutionCache( + this._basePath, (fileName: string) => fileName); + } // We enable caching of the filesystem in compilerHost _after_ the program has been created, // because we don't want SourceFile instances to be cached past this point.