I decided to add an ng-add schematic to my library, since there are additional setup steps when installing it past running npm/yarn install. This way, users will be able to run ng add @myorg/mylib
and the schematics will run
I am having difficulty test running the schematic. Angular Guide only mentions how to test generate
schematics, not add
ones. The problem is that the schematic is supposed to run when I install the library, however ng add
command always seems to install the repository version, and not the local one even if I link my library with yarn link
Thanks for your help.
Ok, I got an answer before I submitted the question.
Do
yarn link mylibrary
, and thenng add mylibrary
.ng add
doesn't require the library not to be installed, it will try to install, but fail gracefully if the library is already installed with a warningYour ng-add script probably contains
context.addTask(new NodePackageInstallTask());
. Since link already "installed" the library in your node_modules, this will fail. The solution is to comment this line out while you're developing, and reenable it before publishing.