Hacker News new | ask | show | jobs
by hanspragt 3153 days ago
Has anyone had success using the AOT tools to build a package of reusable angular components? I was able to use AOT pretty easily for a stand-alone app, but keep running into issues when trying to create a shareable component, and there is not a lot of documentation around this.
3 comments

I have for my day job, but it's _hard_. There isn't a lot of good info out there. Here are a few good sources that I found helpful:

https://medium.com/@isaacplmann/getting-your-angular-2-libra... http://dbarnes.me/writing-an-aot-compliant-angular-library/ https://angular.io/guide/aot-compiler https://angular.io/guide/metadata

Yes, but it can be terrible. Suggestion is to take one of the angular library generators. They really need proper docs on how to set this up properly.
I have, but by using ngc in my gulp build task (had to use gulp for the reason below), unfortunately couldn't make it incremental at that time, so it takes several seconds to re-build when the source is changed.

There is actually another problem when you want to develop reusable UI component library project is that you have to inline style files and template file into ts component.

> There is actually another problem when you want to develop reusable UI component library project is that you have to inline style files and template file into ts component.

We have a webpack-based process, and using the angular2-template-loader will take care of this for you. Unfortunately, webpack and aot don't mix well.