So I am adopting a modular JS approach in my next project, all of which is a brand new process to me. It would be appreciated to keep things rather dumbed down, as my current experience is limited.
So I have my private package up on npm:
@name/package-name
Now, my private package consists of several JS files with exports, to keep things modular and clean during dev time.
I consume this package into my new project:
npm i @name/package-name -S
I require my package from my node_modules, using a loader/bundler such as webpack, requireJS, or the like:
var test = require('@name/package-name');
...
//use the imported code
So, this causes the require to enter my package at its defined Entry point.
Now this is where I am confused. Should the installed private package have an 'entry.js' file which has been previously bundled(from the separate JS files) so that single entry file has everything the code in my new project needs to run?
If so this means I run webpack within every module itself to bundle it, as well as run webpack in my new project?
Advice is appreciated, thank you.
via Benji Dawson
No comments:
Post a Comment