Title: dev-server keeps stale code of a linked (`file:`) library after `ng-packagr --watch` rebuilds it (rebuild reported, restart required) · Issue #34728 · angular/angular-cli · GitHub
Open Graph Title: dev-server keeps stale code of a linked (`file:`) library after `ng-packagr --watch` rebuilds it (rebuild reported, restart required) · Issue #34728 · angular/angular-cli
X Title: dev-server keeps stale code of a linked (`file:`) library after `ng-packagr --watch` rebuilds it (rebuild reported, restart required) · Issue #34728 · angular/angular-cli
Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description In a workspace with an application and a separate Angular libr...
Open Graph Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description In a workspace with an...
X Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description In a workspace with an...
Opengraph URL: https://github.com/angular/angular-cli/issues/34728
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dev-server keeps stale code of a linked (`file:`) library after `ng-packagr --watch` rebuilds it (rebuild reported, restart required)","articleBody":"### Command\n\nserve\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\nIn a workspace with an application and a separate Angular library linked with a `file:` dependency, rebuilding the library in watch mode makes `ng serve` print \"Application bundle generation complete\", but the application bundle (`main.js`) still contains the **previous** compiled code of the library. The new code only appears after stopping and restarting `ng serve`.\n\nThe source map embedded in the same `main.js` already contains the **new** library source (`sourcesContent`), while the code is the old one. So the updated `.map` file seems to be re-read, but the content of `libreria.mjs` is reused from a previous build.\n\nI could not determine whether this is the in-memory load cache, the file watcher, or something else.\n\n### Minimal Reproduction\n\n**Setup**\n\n- Windows, project and library in sibling folders (`D:\\...\\proyecto-22` and `D:\\...\\libreria-22`).\n- Library built with `ng build libreria --watch --configuration development` (ng-packagr).\n- App `package.json`: `\"libreria\": \"file:../libreria-22/dist/libreria\"` (npm `install-links=false`, so `node_modules/libreria` is a Junction to `libreria-22\\dist\\libreria`).\n- `preserveSymlinks` is not set (enabling it is not an option for me: the library sources then resolve under the app's folder and breakpoints in the library do not bind in VS Code).\n- `angular.json` of the app:\n\n ```json\n \"build\": {\n \"configurations\": {\n \"development\": {\n \"optimization\": false,\n \"extractLicenses\": false,\n \"sourceMap\": { \"scripts\": true, \"styles\": true, \"vendor\": true }\n }\n }\n },\n \"serve\": {\n \"options\": {\n \"poll\": 1000,\n \"prebundle\": { \"exclude\": [\"libreria\"] }\n }\n }\n ```\n\n- Angular CLI cache enabled (default).\n\n**Steps to reproduce**\n\n1. Create the app and a library (`ng new`, `ng generate library libreria`), and build the library once into `dist/libreria`.\n2. In the app, add `\"libreria\": \"file:../libreria-22/dist/libreria\"` and run `npm install`.\n3. In the library, create a service with a method containing `console.log('v1')`, and call it from the app's root component.\n4. Run `ng build libreria --watch --configuration development` in the library, and `ng serve` in the app.\n5. Change the log in the library service to `console.log('v2')` and wait until ng-packagr finishes.\n\n**Expected:** the dev-server rebuilds and the app runs `v2`.\n\n**Actual:** the terminal prints \"Application bundle generation complete\" but the app still runs `v1`. Searching `main.js` shows the old code:\n\n```js\n// ../libreria-22/dist/libreria/fesm2022/libreria.mjs\n...\nconsole.log(\"v1\"); // old code\n```\n\nwhile the embedded source map has the new source:\n\n```\nsourcesContent: \"... console.log('v2'); ...\"\n```\n\n`dist/libreria/fesm2022/libreria.mjs` on disk does contain the new code. Stopping and restarting `ng serve` fixes it.\n\n**Things I tried without success**\n\n- `poll: 1000` in `serve.options` (with restart).\n- Deleting `.angular/cache` and restarting (works until the next library change).\n- `prebundle.exclude` with the package name.\n- Starting from a shell with the drive letter in uppercase (`D:`) instead of lowercase. \u003cremove this line if you did not launch `ng serve` from that shell>\n\n### Minimum Reproduction\n\nhttps://github.com/LuisEscamillaMartin/repro-linked-lib-stale\n\n### Exception or Error\n\n```text\nNo error. The build reports success.\n```\n\n### Your Environment\n\n```text\nAngular CLI : 22.2.5\nNode.js : 24.21.0\nPackage Manager : npm 11.19.0\nOperating System : win32 x64\n```\n\n### Anything else relevant?\n\nWithout `preserveSymlinks`, the library is bundled into `main.js` from its real path (`../libreria-22/dist/libreria/fesm2022/libreria.mjs`), outside `node_modules`.","author":{"url":"https://github.com/LuisEscamillaMartin","@type":"Person","name":"LuisEscamillaMartin"},"datePublished":"2026-11-16T10:36:26Z","url":"https://github.com/angular/angular-cli/issues/34728"}
| 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:4fe1f2b6-e2da-be6e-b8ee-e3ff0c1ec205 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BDE8:3A4875:2F43725:3F05E5E:6B01DE47 |
| html-safe-nonce | 26e3ce706d7ec9fbc4e64a52447b4f7c184308deead43bed719f5bab25de072f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREU4OjNBNDg3NToyRjQzNzI1OjNGMDVFNUU6NkIwMURFNDciLCJ2aXNpdG9yX2lkIjoiMjIzMTkzNTQyODUyNzc3NTMwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ae1a1596a7c27736448edde79bac9289aca42e62cfa3ba13d873718fa659012 |
| hovercard-subject-tag | issue:6419353647 |
| 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/34728/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a51ee35f137b8cd4ee7a4ef40dcf1c83c86acbf40b585ccd0a33a02013643512/angular/angular-cli/issues/34728 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a51ee35f137b8cd4ee7a4ef40dcf1c83c86acbf40b585ccd0a33a02013643512/angular/angular-cli/issues/34728 |
| og:image:alt | Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description In a workspace with an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LuisEscamillaMartin |
| 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