Tuesday 6 June 2017

When using a private git url for an npm module, how can I configure the consuming application to only use files from the module's dist folder?

I am using angular-cli for my angular application, but because angular-cli currently does not support use for creating a library, I used the seemingly most widely used git project to create my library: https://github.com/jvandemo/generator-angular2-library

My issue is that I don't want to publish my npm module library to the public directory. Instead I want to use the git url directly in my dependencies. During development, this works fine. I can run the build locally and run an npm link inside the "dist" folder and everything is dandy. However when I push my npm module code to git, and then run an npm install in the consuming project, I'm not sure how to set it so that my consuming project just looks inside the dist folder of the module and treats it as if it was the root of the module.

For example, in node_modules/my_private_module, my file structure looks like:

dist/
-- component1
-- compoennt2
-- my_module.metadata.json
-- my_module.d.ts
-- my_module.umd.js
-- index.d.ts
-- index.js
-- package.json
-- README.MD
package.json
README.md

All the files that my application is using are in the /dist folder, but I DO NOT want to specify "dist" in all my imports like

import { myComponent1 } from 'my_private_module/dist';

I want to be able to just specify

import { myComponent } from 'my_private_module";

As I do in development when I run an npm link in the dist folder.

Is there a way I can achieve this?

Thanks



via Eeks33

No comments:

Post a Comment