benji
benji

Reputation: 2451

Bundle local NPM dependencies and publish

I have a project comprised of:

Is is possible to publish mainmodule without publishing module1 and module2? I.e. to somehow bundle the local dependencies inside of mainmodule?

Upvotes: 3

Views: 345

Answers (1)

Salmen Bejaoui
Salmen Bejaoui

Reputation: 865

Are you importing the dependency module using import or require? If yes, yes you can create a unique bundle from your mainmodule using a bundler like webpack. Inside your mainmodule, you just need a package.json file and Webpack installed locally or globally. After that just run this command

webpack mainmodule.js -o bundle.js

and Webpack will bundle all the modules together is just one module.

Upvotes: 3

Related Questions