Skip to content

Commit af1f0da

Browse files
committed
fix(@angular-devkit/build-angular): do not add internal CSS resources files in watch
This change fixes an issue which caused internal virtual inputs to be added to the watch, this cases watchpack to emit a removed event as this file does not exist on disk. We fix this issue, by prefixing `css-resouces` namespace with `angular:` which the input to be filtered out, see: https://github.com/angular/angular-cli/blob/4539961968e90c8c40ed683afe1cf491630a0048/packages/angular_devkit/build_angular/src/tools/esbuild/bundler-context.ts#L251 Closes #26918
1 parent f844e98 commit af1f0da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/stylesheets/css-resource-plugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { readFile } from 'node:fs/promises';
1111
import { extname, join, relative } from 'node:path';
1212
import { LoadResultCache, createCachedLoad } from '../load-result-cache';
1313

14+
const CSS_RESOURCE_NAMESPACE = 'angular:css-resource';
15+
1416
/**
1517
* Symbol marker used to indicate CSS resource resolution is being attempted.
1618
* This is used to prevent an infinite loop within the plugin's resolve hook.
@@ -97,12 +99,12 @@ export function createCssResourcePlugin(cache?: LoadResultCache): Plugin {
9799
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
98100
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
99101
path: relative(build.initialOptions.absWorkingDir ?? '', result.path),
100-
namespace: 'css-resource',
102+
namespace: CSS_RESOURCE_NAMESPACE,
101103
};
102104
});
103105

104106
build.onLoad(
105-
{ filter: /./, namespace: 'css-resource' },
107+
{ filter: /./, namespace: CSS_RESOURCE_NAMESPACE },
106108
createCachedLoad(cache, async (args) => {
107109
const resourcePath = join(build.initialOptions.absWorkingDir ?? '', args.path);
108110

0 commit comments

Comments
 (0)