Skip to content

Commit cbad575

Browse files
committed
fix(@angular/build): ignore virtual esbuild paths with (disabled):
Virtual files generated by esbuild for disabled browser fields leak into the watch list, causing spurious rebuilds in watch mode. Previously, only paths where the suffix was a Node.js builtin module were ignored. Now, any path containing `(disabled):` is ignored as it represents a virtual file that doesn't exist on disk. Fixes #33160 (cherry picked from commit b06849a)
1 parent 6cc9349 commit cbad575

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

packages/angular/build/src/tools/esbuild/bundler-context.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ import {
1313
BuildResult,
1414
Message,
1515
Metafile,
16-
OutputFile,
1716
build,
1817
context,
1918
} from 'esbuild';
2019
import assert from 'node:assert';
21-
import { builtinModules } from 'node:module';
2220
import { basename, extname, join, relative } from 'node:path';
2321
import { LoadResultCache, MemoryLoadResultCache } from './load-result-cache';
2422
import { SERVER_GENERATED_EXTERNALS, convertOutputFile } from './utils';
@@ -489,12 +487,9 @@ function isInternalBundlerFile(file: string) {
489487
return true;
490488
}
491489

492-
const DISABLED_BUILTIN = '(disabled):';
493-
494-
// Disabled node builtins such as "/some/path/(disabled):fs"
495-
const disabledIndex = file.indexOf(DISABLED_BUILTIN);
496-
if (disabledIndex >= 0) {
497-
return builtinModules.includes(file.slice(disabledIndex + DISABLED_BUILTIN.length));
490+
// Any (disabled): path is a virtual esbuild entry that doesn't exist on disk
491+
if (file.includes('(disabled):')) {
492+
return true;
498493
}
499494

500495
return false;

0 commit comments

Comments
 (0)