Skip to content

Symlink {virtual_layer}/node_modules to /workspace/node_modules#737

Merged
joshwlewis merged 7 commits intomainfrom
fix-pnpm-dep-binary-deps
Dec 1, 2023
Merged

Symlink {virtual_layer}/node_modules to /workspace/node_modules#737
joshwlewis merged 7 commits intomainfrom
fix-pnpm-dep-binary-deps

Conversation

@joshwlewis
Copy link
Copy Markdown
Member

@joshwlewis joshwlewis commented Nov 30, 2023

This PR introduces a symlink from {virtual_layer}/node_modules to /workspace/node_modules. This allows application dependency binaries stored in {virtual_layer}/store/ to find their own dependencies via the node module resolver in an ancestor path's node_modules.

This should solve issues like #712, where application dependencies installed with pnpm are unable to locate their dependencies.

This PR also changes the final destination of artifacts in the virtual layer. They are now one layer deeper, e.g./layers/heroku_nodejs-pnpm-install/virtual/store/[email protected] instead of /layers/heroku_nodejs-pnpm-install/virtual/[email protected]. The virtual layer is not cached and is instead created each build, which should mean that this change will not negatively impact existing/cached builds. Other symlink strategies were considered, but ruled out:

  • We can't write arbritary files in /layers/ or /layers/heroku_nodejs-pnpm-install/ due to CNB constraints, so the symlink can't go here.
  • If we tried to write the symlink into the same dir as the virtual contents (/layers/heroku_nodejs-pnpm-install/virtual) before pnpm install, pnpm install would delete the symlink.
  • If we tried to write the symlink into the same dir as the virtual contents (/layers/heroku_nodejs-pnpm-install/virtual) after pnpm install, the symlink wouldn't be there during install, preinstall lifecycle hooks, so lifecycle hooks that use dependencies with dependencies would fail.

Symlink {virtual_layer}/node_modules to /workspace/node_modules. This
allows application dependency binaries stored in {virtual_layer}/store/
to find their own dependencies in an ancestor path's node_modules.
@joshwlewis joshwlewis marked this pull request as ready for review November 30, 2023 21:14
@joshwlewis joshwlewis requested a review from a team as a code owner November 30, 2023 21:14
@joshwlewis joshwlewis enabled auto-merge (squash) December 1, 2023 18:55
@joshwlewis joshwlewis merged commit 6dd54e3 into main Dec 1, 2023
@joshwlewis joshwlewis deleted the fix-pnpm-dep-binary-deps branch December 1, 2023 19:04
colincasey pushed a commit that referenced this pull request Dec 1, 2023
## heroku/nodejs

### Changed

- Updated `heroku/nodejs-corepack` to `2.4.0`.
- Updated `heroku/nodejs-engine` to `2.4.0`.
- Updated `heroku/nodejs-npm-engine` to `2.4.0`.
- Updated `heroku/nodejs-npm-install` to `2.4.0`.
- Updated `heroku/nodejs-pnpm-install` to `2.4.0`.
- Updated `heroku/nodejs-yarn` to `2.4.0`.

## heroku/nodejs-corepack

- No changes.

## heroku/nodejs-engine

- Added Node.js version 21.3.0.
- Added Node.js version 18.19.0.
### Added

- Added Node.js version 21.2.0.
- Added Node.js version 20.10.0.

## heroku/nodejs-function

### Changed

- Updated `heroku/nodejs-engine` to `2.4.0`.
- Updated `heroku/nodejs-function-invoker` to `2.4.0`.
- Updated `heroku/nodejs-npm` to `2.4.0`.

## heroku/nodejs-function-invoker

- No changes.

## heroku/nodejs-npm

### Changed

- This buildpack now implements Buildpack API 0.7 instead of 0.6. ([#721](#721))

## heroku/nodejs-npm-engine

### Added

- Added npm version 10.2.4.
- Added npm version 9.9.2.

## heroku/nodejs-npm-install

### Fixed

- Detection will report a failure instead of throwing an error when there is no `package.json` file in the application directory. ([#733](#733))

## heroku/nodejs-pnpm-install

### Added

- New symlink from {virtual_layer}/node_modules to {app_dir}/node_modules to
  support transitory dependency resolution and nuxt apps.
  ([#737](#737))

### Changed

- Virtual store artifact location has moved form {virtual_layer}/* to
  {virtual_layer}/store/* to support transitory dependency resolution and
  nuxt apps. ([#737](#737))

## heroku/nodejs-yarn

### Added

- Added Yarn version 4.0.2.
- Added Yarn version 3.7.0.
- Added Yarn version 1.22.21.
- Added Yarn version 1.22.20.

Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants