heroku-buildpack-monorepo icon indicating copy to clipboard operation
heroku-buildpack-monorepo copied to clipboard

Packages depencies with each other ?

Open cyrilchapon opened this issue 4 years ago • 4 comments

What if the different packages have dependency on each other ?

Moving app to root will kill those dependencies before installing and resolving dependencies

cyrilchapon avatar Jul 26 '19 09:07 cyrilchapon

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.

joeyfigaro avatar Mar 30 '21 19:03 joeyfigaro

Did anyone of you find a solution to this problem?

philipaarseth avatar Apr 09 '22 08:04 philipaarseth

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.

paulmelnikow avatar Dec 04 '23 19:12 paulmelnikow

I'd propose the following solution here (as an alternative to #17):

  1. In this buildpack, when moving the content from APP_BASE to the new root, use cp -RL instead of mv. This has the effect of preserving all symlinks within APP_BASE.
  2. In the application, create a dependencies folder inside APP_BASE, with a set of symlinks pointing to the common packages living outside APP_BASE.
  3. In the application's dependency manifest, reference the dependencies through these symlinks (e.g. file:dependencies/my-lib, instead of file:../../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:

  1. The dependencies are organized flat, in a single parent folder, and reference each other using e.g. file:../other-lib.
  2. The application keeps the symlinks flattened the same way in dependencies.
  3. The application dependencies folder includes a symlink for both the direct dependencies and their transitive dependencies.

paulmelnikow avatar Dec 06 '23 21:12 paulmelnikow