From ca4426150f99d334f132ea88e80c994422da9202 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:04:42 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): normalize paths when invalidating stylesheet bundler To avoid incorrectly invalidating the stylesheet bundler within the application builder on Windows, the paths of changed files are now first normalized. This ensures that any changed files properly cause affected component stylesheets to be reprocessed. --- .../src/tools/esbuild/angular/component-stylesheets.ts | 6 ++++-- tests/legacy-cli/e2e/tests/basic/rebuild.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/tools/esbuild/angular/component-stylesheets.ts b/packages/angular_devkit/build_angular/src/tools/esbuild/angular/component-stylesheets.ts index 5a85646c9ce2..3f744987eba8 100644 --- a/packages/angular_devkit/build_angular/src/tools/esbuild/angular/component-stylesheets.ts +++ b/packages/angular_devkit/build_angular/src/tools/esbuild/angular/component-stylesheets.ts @@ -111,11 +111,13 @@ export class ComponentStylesheetBundler { return; } + const normalizedFiles = [...files].map(path.normalize); + for (const bundler of this.#fileContexts.values()) { - bundler.invalidate(files); + bundler.invalidate(normalizedFiles); } for (const bundler of this.#inlineContexts.values()) { - bundler.invalidate(files); + bundler.invalidate(normalizedFiles); } } diff --git a/tests/legacy-cli/e2e/tests/basic/rebuild.ts b/tests/legacy-cli/e2e/tests/basic/rebuild.ts index e3bc9ec2384a..633ccec6f4f2 100644 --- a/tests/legacy-cli/e2e/tests/basic/rebuild.ts +++ b/tests/legacy-cli/e2e/tests/basic/rebuild.ts @@ -116,7 +116,7 @@ export default async function () { const response = await fetch(`http://localhost:${port}/styles.css`); const body = await response.text(); if (!body.match(/color:\s?green/)) { - throw new Error('Expected component CSS to update.'); + throw new Error('Expected global CSS to update.'); } } }