From f2f15c089361bb55a809563c55a327887a401d43 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 9 Jun 2021 17:24:26 -0400 Subject: [PATCH] fix(@ngtools/webpack): disable caching for ngcc synchronous Webpack resolver The ngcc resolver must be synchronous to integrate with TypeScript which is only synchronous. If the Webpack resolver cache option is enabled when creating a resolver, the resolver will become asynchronous after a rebuild due to the internal implementation of the resolver caching. To prevent this change in behavior, caching is disabled for the ngcc resolver. The ngcc resolver is only used the first time each dependency is used by the application. --- packages/ngtools/webpack/src/ivy/plugin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/ngtools/webpack/src/ivy/plugin.ts b/packages/ngtools/webpack/src/ivy/plugin.ts index a8e06228cb5c..f0bde1321281 100644 --- a/packages/ngtools/webpack/src/ivy/plugin.ts +++ b/packages/ngtools/webpack/src/ivy/plugin.ts @@ -66,6 +66,8 @@ function initializeNgccProcessor( const errors: string[] = []; const warnings: string[] = []; const resolver = compiler.resolverFactory.get('normal', { + // Caching must be disabled because it causes the resolver to become async after a rebuild + cache: false, extensions: ['.json'], useSyncFileSystemCalls: true, });