unfold / heroku-buildpack-pnpm

Run PNPM install on Heroku
MIT License
38 stars 39 forks source link

Extend pnpm_prune_devdependencies to support monorepos and prune subfolders #45

Closed TamoMaes closed 1 year ago

TamoMaes commented 1 year ago

This pull request updates the pnpm_prune_devdependencies function in the Heroku buildpack to support monorepos and prune dev dependencies in subfolders as necessary. The updated function checks for the presence of a pnpm-workspace.yaml file or a workspaces field in the root package.json file to determine if the project is a monorepo. If it is a monorepo, the function iterates through all subfolders (depth=2) containing a package.json file and prunes their dev dependencies using the pnpm prune --prod command.

Changes in this PR include:

  1. Update the pnpm_prune_devdependencies function to check for a monorepo configuration.
  2. If a monorepo is detected, find all subfolders containing a package.json file and prune their dev dependencies.
  3. Preserve the existing behavior for non-monorepo projects.

This enhancement allows developers to optimize slug size for monorepo projects by removing unnecessary dev dependencies from subfolders, resulting (hopefully) in faster deployment times and improved performance on Heroku.