Skip to content

Commit 56c3e26

Browse files
committed
fix(@ngtools/webpack): fix for TypeScript module resolution cache missing in old version
1 parent 0c1ae7a commit 56c3e26

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/@ngtools/webpack/src/plugin.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class AotPlugin implements Tapable {
5151
private _compilerOptions: ts.CompilerOptions;
5252
private _angularCompilerOptions: any;
5353
private _program: ts.Program;
54-
private _moduleResolutionCache: ts.ModuleResolutionCache;
54+
private _moduleResolutionCache?: ts.ModuleResolutionCache;
5555
private _rootFilePath: string[];
5656
private _compilerHost: WebpackCompilerHost;
5757
private _resourceLoader: WebpackResourceLoader;
@@ -253,10 +253,12 @@ export class AotPlugin implements Tapable {
253253
this._rootFilePath, this._compilerOptions, this._compilerHost);
254254

255255
// We use absolute paths everywhere.
256-
this._moduleResolutionCache = ts.createModuleResolutionCache(
257-
this._basePath,
258-
(fileName: string) => this._compilerHost.resolve(fileName),
259-
);
256+
if (ts.createModuleResolutionCache) {
257+
this._moduleResolutionCache = ts.createModuleResolutionCache(
258+
this._basePath,
259+
(fileName: string) => this._compilerHost.resolve(fileName),
260+
);
261+
}
260262

261263
// We enable caching of the filesystem in compilerHost _after_ the program has been created,
262264
// because we don't want SourceFile instances to be cached past this point.

0 commit comments

Comments
 (0)