angular-cli: Html changes not detected in watched library by "ng serve --aot"

🐞 Bug report

Command

- [ ] new
- [ ] build
- [X] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

Html changes are not detected in library when starting project using ng serve --aot. Library is built using --watch flag and main project is served with --aot. On html change build and serve process are triggered and page refreshes but with no changes in html. Typescript changes are visible after rebuild. Html change is only visible when you restart ng serve --aot process.

Without --aot flag everything is working as intended.

Same problem exists with npm linked external library (not in the same project).

🔬 Minimal Reproduction

I made a small repro of the problem: https://github.com/V3nsla/aot-lib-html-changes

To reproduce the problem build library using --watch flag (ng build lib --watch) and start main project using ng serve --aot.

Make some changes in the template of LibComponent and save to trigger build process. After main project is recompiled html changes are not reflected.

🌍 Your Environment


Angular CLI: 7.3.0
Node: 10.12.0
OS: win32 x64
Angular: 7.2.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.0
@angular-devkit/build-angular      0.13.0
@angular-devkit/build-ng-packagr   0.13.0
@angular-devkit/build-optimizer    0.13.0
@angular-devkit/build-webpack      0.13.0
@angular-devkit/core               7.3.0
@angular-devkit/schematics         7.3.0
@angular/cli                       7.3.0
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.3.0
@schematics/angular                7.3.0
@schematics/update                 0.13.0
ng-packagr                         4.7.0
rxjs                               6.3.3
typescript                         3.2.4
webpack                            4.29.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 15
  • Comments: 33

Most upvoted comments

@Nagarjuna-B you simply have to edit the paths in root tsconfig.json

{
  "compilerOptions": {
    "paths": {
      "@my/package": ["dist/my/package"]
    }
 }
}

from: "@my/package": ["dist/my/package"] to: "@my/package": ["src/my/package/src/public_api.ts"]

I’ve additionally added an index.ts to the package src with reexports public_api.ts. So i only need:

"@my/package": ["src/my/package/src"]