From 489471417fdfa9a1c7a1c8e001b6c9e99833a178 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 28 May 2021 14:16:53 +0200 Subject: [PATCH] fix(@ngtools/webpack): normalize paths when adding file dependencies This caused Webpack to mark all TypeScript files as removed after the first compilation on Windows because the file separators didn't match Closes #20891 --- packages/ngtools/webpack/src/ivy/plugin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/ngtools/webpack/src/ivy/plugin.ts b/packages/ngtools/webpack/src/ivy/plugin.ts index c1631f919a42..b1f79ccc70a5 100644 --- a/packages/ngtools/webpack/src/ivy/plugin.ts +++ b/packages/ngtools/webpack/src/ivy/plugin.ts @@ -268,8 +268,9 @@ export class AngularWebpackPlugin { continue; } - // Ensure all program files are considered part of the compilation and will be watched - compilation.fileDependencies.add(sourceFile.fileName); + // Ensure all program files are considered part of the compilation and will be watched. + // Webpack does not normalize paths. Therefore, we need to normalize the path with FS seperators. + compilation.fileDependencies.add(externalizePath(sourceFile.fileName)); // Add all non-declaration files to the initial set of unused files. The set will be // analyzed and pruned after all Webpack modules are finished building.