I am newbie to Angular4 and need some helps I am finding the way to make common Angular module for other to reuse like Angular Material for example
After the research, I have some questions as below
- Should I publish to git or npm
- Can current version of CLI 1.2.4 help on pack and publish
- I found two library https://www.npmjs.com/package/angular-npm-module-seed and https://github.com/jvandemo/generator-angular2-library. Should I use them or there is another ways
- What is the common ways you guys do on sharing component with team
Thanks for all you helps
Edit: I am using Angular CLI to create project
2 Answers 2
If you gonna use the module inside the same project (aka same application) then it's easier to simply make it as a part of the application and import it in the root module.
Else, if you want to make a standalone module it's best to publish it to npm and use as a dependency. Then your team can reuse it in any project by simply adding it to package.json.
Here's a reference on how to create an angular 4 node module: http://blog.angular-university.io/how-to-create-an-angular-2-library-and-how-to-consume-it-jspm-vs-webpack/
Comments
I must say that you are thinking in right direction. The preferred method is to use generator-angular2-library and generate a skeleton. You may publish it to npm repo or your own private repo if your organization provides one. Here is an article that should help you achieving this: https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464