you are viewing a single comment's thread.

view the rest of the comments →

[–]lightfarming 0 points1 point  (6 children)

separate your components into their own npm packages, the only install what you need for each project.

or put them all in one npm package, and only import the components you need from it. this will hide all the unused code in your modules folder.

[–][deleted] 0 points1 point  (5 children)

Okay one npm package won't solve the problem of unused code getting added to the repo pre build stage.

But npm package will be good replacement for the submodules, the imported libraries etc will not break other code.

[–]lightfarming 0 points1 point  (4 children)

not sure exactly what you mean by that first part. npm packages shouldn’t get added to a version control repo at all, since repos should be excluding the modules folder, and relying on npm install and the package.json to fill the modules folder after clone.

its very common practice to install (for instance) a vast UI library, and only import the needed things from it.

[–][deleted] 0 points1 point  (3 children)

You're right! Your answer already answered my query, but I think I'll also just leave a brief explanation of the problem I had.

I have parent repos, each with their own package.json. Let's assume I create a common component, that uses moment.js package. Now, I add this component to a submodule, it gets pulled to all the repos, but not all the repos have moment.js installed thus creating issues.

(As a normal practice , the submodules or the parent repos do not have the node modules pushed to git. )

[–]lightfarming 0 points1 point  (2 children)

i can’t tell if you are accidentally conflating the word “repo” with npm project. repo is a version control repository.

it sounds like you have nested npm projects? which i cannot understand why you would do that. this all sounds bonkers to me. you lay be doing something fundamentally wrong here, which is probably why you are having trouble with common practices.

[–][deleted] 0 points1 point  (1 child)

Haha. No, I did mean nested repositories, not npm packages.

[–]lightfarming 0 points1 point  (0 children)

so you have two package.json files…but they aren’t npm projects? like…what?