DEV Community

Discussion on: Best Practice Tips for Writing Your JS Modules

 
ndesmic profile image
ndesmic

Node users will typically only import the the package's main script as that's just the general convention. However if the codebase it big enough you might break it into separate packages using a monorepo pattern like babel etc. Otherwise if there's code that's internal to the module but not for re-export, or if you have name clashes you'll need to manually write all the imports and exports in the index.js instead of using *. Personally I wouldn't find using multiple import paths to be a big deal but you should make sure it's documented what is in each as it might not be expected.

Thread Thread
 
jespertheend profile image
Jesper van den Ende

That sounds like a good idea. Thanks for the advice!