heroku-buildpack-monorepo
heroku-buildpack-monorepo copied to clipboard
Packages depencies with each other ?
What if the different packages have dependency on each other ?
Moving app to root will kill those dependencies before installing and resolving dependencies
Have identified same issue as @cyrilchapon – I've got one application in my monorepo with a handful of sibling/adjacent packages that it depends on. Application's deps can't be installed using this approach/buildpack.
Did anyone of you find a solution to this problem?
Our environment looks like this:
unpublished-packages/first-dep
unpublished-packages/second-dep
unpublished-packages/third-dep
apps/first-app
apps/second-app
It's using npm, with relative file dependencies in each app's package.json.
The reason we're using a monorepo is to share code between the applications, so it would be helpful if this case were supported.
I'd propose the following solution here (as an alternative to #17):
- In this buildpack, when moving the content from APP_BASE to the new root, use
cp -RL
instead ofmv
. This has the effect of preserving all symlinks within APP_BASE. - In the application, create a
dependencies
folder inside APP_BASE, with a set of symlinks pointing to the common packages living outside APP_BASE. - In the application's dependency manifest, reference the dependencies through these symlinks (e.g.
file:dependencies/my-lib
, instead offile:../../libs/my-lib
). Since this buildpack will have turned those symlinks into copies, the language-specific buildpacks should be able to resolve them.
This will also support transitive dependencies, so long as the following are adhered to:
- The dependencies are organized flat, in a single parent folder, and reference each other using e.g.
file:../other-lib
. - The application keeps the symlinks flattened the same way in
dependencies
. - The application
dependencies
folder includes a symlink for both the direct dependencies and their transitive dependencies.