Title: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles · Issue #33160 · angular/angular-cli · GitHub
Open Graph Title: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles · Issue #33160 · angular/angular-cli
X Title: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles · Issue #33160 · angular/angular-cli
Description: Issue: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles Command serve Is this a regression? Yes — this did not occur with the Webpack-based builder (@angular-devkit/build-angular:browser). ...
Open Graph Description: Issue: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles Command serve Is this a regression? Yes — this did not occur with the Webpack-based builder (...
X Description: Issue: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles Command serve Is this a regression? Yes — this did not occur with the Webpack-based builder (...
Opengraph URL: https://github.com/angular/angular-cli/issues/33160
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles","articleBody":"# Issue: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles\n\n## Command\n\n`serve`\n\n## Is this a regression?\n\nYes — this did not occur with the Webpack-based builder (`@angular-devkit/build-angular:browser`). It is specific to the `@angular-devkit/build-angular:application` builder (esbuild/Vite).\n\n## Description\n\nWhen running `ng serve` (or `nx serve` with the Angular dev-server), the application builds successfully, then **immediately** triggers \"Changes detected. Rebuilding...\" without any user file changes. This results in a full second rebuild on every serve startup, adding ~30–50 seconds of wasted time.\n\n### Root Cause\n\nThe issue is in `isInternalBundlerFile()` in `bundler-context.ts`. This function is responsible for filtering out non-real files from the watch file list. It currently handles `(disabled):` paths only when the suffix is a Node.js builtin module (e.g., `fs`, `path`, `util`):\n\n```typescript\n// Current code (v19.2.25):\nfunction isInternalBundlerFile(file: string): boolean {\n // ...\n const DISABLED_BUILTIN = '(disabled):';\n const disabledIndex = file.indexOf(DISABLED_BUILTIN);\n if (disabledIndex >= 0) {\n return builtinModules.includes(file.slice(disabledIndex + DISABLED_BUILTIN.length));\n }\n return false;\n}\n```\n\nHowever, esbuild also generates `(disabled):` prefixed inputs for **browser-field disabled files** — i.e., when a third-party package has `\"browser\": { \"./some-file.js\": false }` in its `package.json`. In this case, esbuild records the input as:\n\n```\n(disabled):node_modules/object-inspect/util.inspect\n```\n\nSince `\"node_modules/object-inspect/util.inspect\"` is not in `builtinModules`, `isInternalBundlerFile()` returns `false`, and this non-existent path gets added to the watch file list.\n\nThe path is then joined with the workspace root to form:\n```\nP:\\Projects\\my-app\\(disabled):node_modules\\object-inspect\\util.inspect\n```\n\nWatchpack (the underlying file watcher) detects that this file does not exist and reports it as \"removed\", triggering an immediate rebuild.\n\n### Specific package triggering this\n\n[`object-inspect`](https://www.npmjs.com/package/object-inspect) (v1.13.4) — a transitive dependency commonly pulled in via `qs` → `side-channel` → `object-inspect`. Its `package.json` contains:\n\n```json\n{\n \"browser\": {\n \"./util.inspect.js\": false\n }\n}\n```\n\nAnd `util.inspect.js` contains:\n```js\nmodule.exports = require('util').inspect;\n```\n\nThis is a legitimate pattern — the package disables the Node.js `util.inspect` wrapper in browser environments. But esbuild's metafile input entry `(disabled):node_modules/object-inspect/util.inspect` is not properly filtered by the Angular builder.\n\n### Suggested Fix\n\nChange `isInternalBundlerFile()` to treat **any** path containing `(disabled):` as internal, not just Node.js builtins:\n\n```typescript\nfunction isInternalBundlerFile(file: string): boolean {\n if (file[0] === '\u003c' && file.at(-1) === '>') {\n return true;\n }\n // Any (disabled): path is a virtual esbuild entry that doesn't exist on disk\n if (file.includes('(disabled):')) {\n return true;\n }\n return false;\n}\n```\n\nThis is safe because `(disabled):` is an esbuild-internal convention for files that have been stubbed out (whether builtins or browser-field disabled files). None of these paths exist on disk, so watching them is always incorrect.\n\n## Minimal Reproduction\n\n1. Create a new Angular 19 application using the `application` builder\n2. Install a package that depends on `object-inspect` (e.g., `npm install qs`)\n3. Import it somewhere in the app: `import qs from 'qs';`\n4. Run `ng serve`\n5. Observe:\n - Build completes successfully\n - \"Watch mode enabled. Watching for file changes...\" appears\n - Immediately followed by \"Changes detected. Rebuilding...\" (with no user action)\n\nTo confirm the cause, add this line before the `for await` loop in `build-action.js`:\n```js\nrequire('node:fs').writeFileSync('watcher-debug.log', changes.toDebugString(), 'utf8');\n```\n\nThe log will show:\n```json\n{\n \"added\": [],\n \"modified\": [],\n \"removed\": [\n \"P:\\\\path\\\\to\\\\project\\\\(disabled):node_modules\\\\object-inspect\\\\util.inspect\"\n ]\n}\n```\n\n## Your Environment\n\n```\nAngular CLI: 19.2.25\nNode: 20.12.2\nPackage Manager: npm 10.8.3\nOS: win32 x64\n\nAngular: 19.2.21\n\nPackage Version\n---------------------------------------------------------\n@angular-devkit/architect 0.1902.25\n@angular-devkit/build-angular 19.2.25\n@angular-devkit/core 19.2.25\n@angular/build 19.2.25\n@angular/cli 19.2.25\n```\n\n## Anything else relevant?\n\n- The issue likely affects **any** package using the `\"browser\": { \"./file.js\": false }` pattern in `package.json`. `object-inspect` is just one common example.\n- The problem is Windows-specific in terms of symptoms (watchpack on Windows uses `ReadDirectoryChangesW` which is more sensitive), but the underlying bug (adding non-existent paths to the watch list) exists cross-platform.\n- A previous related issue [#25197](https://github.com/angular/angular-cli/issues/25197) was fixed via [#26182](https://github.com/angular/angular-cli/pull/26182) (ignoring dot-directories). This is a different manifestation of the same class of problem.\n- The relevant source file is: `packages/angular/build/src/tools/esbuild/bundler-context.ts`, function `isInternalBundlerFile()`.\n","author":{"url":"https://github.com/fipil","@type":"Person","name":"fipil"},"datePublished":"2026-05-11T14:58:28Z","url":"https://github.com/angular/angular-cli/issues/33160"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5c197da3-0e7a-2875-c8c4-e3d16106fd30 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E844:928E2:1DCB070:27BA466:6B016F62 |
| html-safe-nonce | a9061b953f379e002fe1dbe00acb1ddd971875679e648b08ae550713d84dfb33 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODQ0OjkyOEUyOjFEQ0IwNzA6MjdCQTQ2Njo2QjAxNkY2MiIsInZpc2l0b3JfaWQiOiI4NTExMzQ2MzY0NTQ0ODA2NzU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9331838841d210d54bdec8416396cc114c127b2e04276f66afcd6ce59f293c2d |
| hovercard-subject-tag | issue:4421862192 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33160/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5210a1c1a1b1d06b491f2514f4ca4739e2f7e87c28dfe450372f79122dc078e/angular/angular-cli/issues/33160 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5210a1c1a1b1d06b491f2514f4ca4739e2f7e87c28dfe450372f79122dc078e/angular/angular-cli/issues/33160 |
| og:image:alt | Issue: Dev server triggers spurious rebuild due to browser-field disabled files leaking into watchFiles Command serve Is this a regression? Yes — this did not occur with the Webpack-based builder (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fipil |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width