0

During development of angular libraries, I build the libraries on-the-fly using the ng build <lib> --watch. Setup is according to the official Angular docs at: https://angular.io/guide/creating-libraries I am symlinking the libraries into my project with npm link. My angular 11 project is compiled using the Ivy compiler. My library is using the View Engine compiler. The ng serve command uses ngcc to add the Ivy specific extras to the library (the build artifact in dist)

However, this approach does not work anymore for a new Angular 11 project. Everytime that the library gets rebuilt by the watcher, the application served by ng serve loses track and needs to be restarted afresh.

I tried downgrading angular to 10.x and sychronized the typescript compiler version in the library and the application project.

Restarting the ng serve of the project leads to: Tried to overwrite *.component.d.ts.__ivy_ngcc_bak with an ngcc back up file, which is disallowed. all the time. Only thing that helps in that case is restarting the ng build <lib> --watch process.

It seems to me that the in-limbo status of Ivy has thoroughly broken the library development experience using npm link.

Has anyone ideas about what has changed in Angular 11 that causes this problem?

jjmurre
  • 392
  • 4
  • 15
  • Adding the out param could be a fix for it. `ng build --watch -o dist/`. Let's give it a try! Thank you :) – Salahuddin Ahmed Apr 09 '21 at 17:57
  • It seems the -o (--output-path) has only recently been added. My library project is still angular-cli version 10.2.3 and does not support the -o flag unfortunately. – jjmurre Apr 10 '21 at 13:26

1 Answers1

0

I came across a nice solution that did not work for Angular 11, however, after downgrading to Angular 10, this works. The idea is to add an extra build configuration to the library for compiling in Ivy mode. Even ng build <lib> --watch is possible with this approach.

The solution is described here: https://github.com/angular/angular/issues/33395#issuecomment-693306453

jjmurre
  • 392
  • 4
  • 15