rebuild icon indicating copy to clipboard operation
rebuild copied to clipboard

[Suggestion] Doesn't Play Well with Mono-Repo Projects (Lerna)

Open tonyanziano opened this issue 6 years ago • 4 comments

Hello,

Currently our project uses lerna to manage our mono repo of several sub-packages. So we have the following project structure:

root
-- package.json
-- packages
-- -- subPackage1
-- -- -- package.json
-- -- subPackage2
-- -- -- package.json
-- -- etc.

However, we "hoist" all of our dependencies so that when we install all the dependencies, the structure looks like this:

root
-- package.json
-- node_modules <---- where all of the dependencies are installed for all sub packages
-- packages
-- -- subPackage1
-- -- -- package.json
-- -- subPackage2
-- -- -- package.json
-- -- etc.

This means that when I run electron-rebuild from the root to try to rebuild a dependency of subPackage1, electron-rebuild checks the package.json inside of /root to see if the package is a dependency, and can't find it. This is because it is actually declared as a dependency of subPackage1 inside of root/packages/subPackage1/package.json. That means that I have to add the dependency to the root package.json just so that electron-rebuild can find it and rebuild it, even though it's in the root /node_modules/ directory where it is scanning.

It would be great if I could tell electron-rebuild what package.json to check against when scanning so that I wouldn't have to declare the package as a dependency in my root directory just to satisfy electron-rebuild.

Example: electron-rebuild --module-dir . --package-json ./packages/app/main/package.json

tonyanziano avatar May 29 '19 23:05 tonyanziano

~~Nevermind, I figured out how to accomplish this.~~

~~In my case I had to run the following command from the root/packages/subPackage1/ directory:~~

~~../../node_modules/.bin/electron-rebuild -w <packageName> -m ../..~~

~~This way it checks the dependency list of root/packages/subPackage1/package.json but looks for the dependency to rebuild inside of root/node_modules/.~~

Actually, this only worked because my root package.json had it listed as a dependency. So this would still be a nice feature.

tonyanziano avatar May 29 '19 23:05 tonyanziano

Yes, this is very much needed. For me, electron-rebuild runs, doesn't do anything, and exits with a green checkmark. This is really annoying.

rm-rf-etc avatar Oct 07 '19 15:10 rm-rf-etc

This wasn't working for me. The install hook won't run if it's not declared in the root package.json and I run yarn install from the root (sometimes I run yarn install from my package root).

After adding the install hook to the root package.json, along with electron, electron-rebuild, and serialport, under dependencies, then it finally rebuilt correctly. Perhaps some of these aren't needed, will have to test later to determine what the minimum is that's required for it to work.

rm-rf-etc avatar Oct 07 '19 15:10 rm-rf-etc

Yes, this is very much needed. For me, electron-rebuild runs, doesn't do anything, and exits with a green checkmark. This is really annoying.

Experiencing same problem with yarn workspaces.

It runs, mentions the library that it's building, exits with a green checkmark, but no artifacts are produced.

tomsseisums avatar Jun 01 '20 15:06 tomsseisums