-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi! Thanks so much for this package, it seems to be the only public solution for actually copying local packages into their clients' node_modules folder. Super useful for testing. I'm actually planning to use it in a production monorepo + microservices layout where the microservice bundling requires all dependencies to be in a single directory subtree (no symlinks to a global util folder or something).
One limitation I've discovered is that nested local dependencies don't currently work. That is, if local package App depends on local package Lib that depends on local package Util, npx install-local path/to/Lib won't pull in Util as well. I imagine this is because running npm pack on Lib doesn't bundle the Util dependency and adding the Lib tarball to Client doesn't respect the (custom) localDependencies field in lib/package.json (or associated tarball).
Possible solutions:
- Adding Util to Lib's bundledDependencies solves this problem but then makes running
npm installin the Lib package fail with "No valid versions available for Util." This happens even if install-local is run in npm's preinstall hook, I assume because npm install cleans out all dependencies not inpackage-lock.jsonfrom node_modules/ , andpackage-lock.jsonisn't updated when install-local adds local dependencies. - Declaring Util as a peerDependency doesn't work because you would have to point to a tarball or external package, and one of the great things about this library is that it hides tarball creation.
- My Solution: Manually hoist all localDependencies of Lib to App, then run npx install-local. Manual works for a small dependency tree but is super annoying as the trees grow. In particular it isn't as simple as copy-pasting- you need update all the relative paths to be correct w.r.t. your client package. Still, doable for small repos.
It seems like this would be relatively easy to do as part install-local --save, although we'd have to be careful about messy/invalid/circular dependency trees. But it would make this solution a little more fully fledged. npm would continue to beautifully handle all the non-local dependency resolution (hoisting shared versions, installing nested local versions, etc).
I'm super psyched to have discovered this package and would love to hear what people more familiar with the package think of this idea!