Building submodules with npm individually

I’m working on building myself a portfolio site. I’m publishing my site from a public repository that will eventually contain several submodules (it only has one right now). Currently, I’m building my site by using npm run.

This works great for one repository. The issue is that I have each of the submodules set up as their own npm packages. Each submodule has an individual package.json, package-lock.json, and node_modules/.

In a perfect world, I’d like to set my site up so that each submodule builds individually. I thought about setting up a script that’d look through every directory (recursively), find any with a package.json, and run that directory’s npm script. I ran into a wall when I realized that the compiler would have to checkout into those directories. Since Netlify doesn’t use bash, I’m not sure how I’d do that.

I realize that I could just have my main repository require every submodule’s dependencies as well, but that’d be a major pain. I work in each repository individually, and then I update the submodules in the main one.

If anyone knows a way to do this or has any advice, it’d be much appreciated!

This might help:

Just as I said there, I’m not 100% sure, but yeah as far as I know, it’s not very easily possible (if at all it is).

That’s for the help @hrishikesh. I figured that was the case, I’m going to play around with GitHub Actions again, and see if I can get that to work.

That’s a great idea. Don’t forget to post your solution if you find it, so it can help many more people.

1 Like