trekhleb / angular-library-seed

🌾 Seed project for Angular libraries that are AOT/JIT compatible and that use external SCSS-styles and HTML-templates
MIT License
200 stars 87 forks source link

Question: How to make library with multiple entry points? #12

Open jbeckton opened 7 years ago

jbeckton commented 7 years ago

I am using your seed for a library I am building that is going to be kind of large. I am trying to set up my library source so that I can have multiple entry points like...

@mylib/security @mylib/logging @mylib/ui ...

This way consumers of the lib will be able to import modules and components from the appropriate location in the library.

ShaneYu commented 7 years ago

Perhaps you could take a similar approach to what ng-bootstrap did? You can import the entire log via the NgbModule or import individual modules. Tree shaking will do the rest.

https://github.com/ng-bootstrap/ng-bootstrap/tree/master/src

Kamilius commented 6 years ago

@jbeckton Based on angular-library-seed (which was already mentioned by @ShaneYu), I'm developing two kinds of things:

Basically, whole idea is based on module per component, and a '.forRoot()' convention. Which in advance helps to successfully tree shake unused stuff via webpack or a rollup.

Don't include library scripts as a separate files. Just npm/yarn add a whole library, use only things you need and - treeshake unneeded during prod build.