-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating npm projects/modules #2978
Comments
Anyone can help with it? |
@piernik this issue has come up a couple of times. At the moment you will have to do some of your own tooling to get something ready to be published to npm. |
I see. Hope it will be included very soon. Thanks for response. |
@piernik, you can check out angular/material2 for an example of a working library. |
Struggling hard with this as well, +1 for requested feature. If angular-cli did this natively my life would be wonderful right now |
@deebloo any recommendation in tooling setup? not sure exactly what to deliver to consuming apps |
So right now for work we have several separate libs we created with the cli. We are only worried about consuming via typescript so I just included an index.ts file at the root of the repo that exports the desired pieces and then install from github. That is working really well for us. |
@deebloo Pardon the questions but I've been working on this for a few days to no avail :) 1.) Do you compile the project before you bring it in as a dependency or do you let the master project take care of that? 2.) Are you bringing it in as an npm dependency or are you cloning the repo locally into the master project? |
@thatchej no worries at all. 1.) right now we just leave everything as typescript and let the master project handle the compiling. so steps to manage: dependencies: {
"my-core": "github:username/repositoryname#v1.0.1"
} This is working well for use for internal libs and such but isn't feasible for public libs and such. Hope this helps! |
Cool, the index.ts file may be the key I am missing. Right now I am pretty much doing the same thing without it, and continue to get some real weird error messages like I'm trying a much more basic strategy with a very simple angular project hand compiled to |
@thatchej let me know how it ends up working for you. I am working on some tooling to help with this that could be used alongside the cli but not ready yet. |
Really interested in the ability to do this too, I'm trying to hand craft this at the moment. I am trying to avoid using lots of relative paths, and would like something like
I've tried using paths and baseUrl in tsconfig, but this causes other problems. @deebloo is there any chance you could give me some pointers on how you import your modules/components into the hosting project? |
@bthharper if you install them with npm you can just import them as you would any other node module |
@deebloo Just realised how stupid I was being ... works a treat! |
@deebloo I've now tried both strategies and continue to get the same issue. It seems to specifically be that the two different versions of Angular 2 are clashing (the master projects version, and the library component version). How are you avoiding this? |
@thatchej peer dependencies |
@deebloo how do I set that up? it's not something I've touched yet |
@thatchej there is just a property in your package.json file called peerDependencies. https://nodejs.org/en/blog/npm/peer-dependencies/ |
I've managed to publish my project to npm. In angular-cli project my module went to single folder (component-warpper). |
@piernik you just made my day ;) |
If these are internal libraries, it's generally better to install from github (as @deebloo suggested). Especially if the libraries are typescript only. |
Heya all, this thread has very nice advice to get libs working right now but I really do have to close it as a dupe of #1692. If I don't conversations will start to diverge instead of being focused in a single thread. Do add your advice there (that issue is marked as FAQ as well), but I want to say that we're looking at really making libs a first class citizen with the CLI, ready to push compiled libs to npm. Don't have a timeline, but that's the plan. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
By default angular-cli creates application (with index.html and all js files). The question is how to, using angular-cli, build npm modules/projects?
I want to create separate modules that I can use in other projects.
Is there some kind of roadmap or tutorial how to build modules to be published on npm?
The text was updated successfully, but these errors were encountered: