Skip to content

Latest commit

 

History

History
150 lines (101 loc) · 9.42 KB

File metadata and controls

150 lines (101 loc) · 9.42 KB

Node.js pnpm install Cloud Native Buildpack

Heroku's official Cloud Native Buildpack for pnpm install.

CI

Registry

This buildpack will install and cache package.json and pnpm-lock.json dependencies using the pnpm install command.

This buildpack relies on and builds on top of the Node.js Engine Cloud Native Buildpack to install Node.js and the Node.js Corepack Cloud Native Buildpack to install pnpm.

What it does

  • Sets up a cacheable content-addressable dependency store.
  • Sets up a non-cacheable virtual dependency store.
  • Modifies pnpm config so that the above content-addressable and virtual stores are used by pnpm install
  • Downloads, stores, and hard links package.json and pnpm-lock.json dependencies with pnpm install --frozen-lockfile.
  • Runs build scripts from package.json, including heroku-prebuild, heroku-build (or build), and heroku-postbuild.
  • Sets the default process type as pnpm start if it's defined in package.json

Features

Supported:

  • pnpm versions 7+
  • pnpm hoist = true mode
  • pnpm hoist = false mode
  • pnpm Plug'n'Play mode.

Unsupported:

  • Optional devDependencies. devDependencies are always installed.
  • Pruning devDependencies. devDependencies are always installed.
  • Arbritrary store-dir or virtual-store-dir locations. This buildpack only supports it's own store locations.

Reference

Detect

This buildpack's bin/detect will only pass if a pnpm-lock.json exists in the project root. This is done to prevent the buildpack from providing indeterminate and unpredictable dependency trees.

Hoist Modes

The hoist = true, hoist = false, shamefully-hoist = false, shamefully-hoist = true configurations are all supported by this buildpack. To use any of these features, make the changes in the project's .npmrc file.

Plug'n'Play

Plug'n'Play is supported. Use node-linker = pnp and symlink = false in the project's .npmrc to enable this mode.

Scripts

After dependencies are installed, build scripts will be run in this order: heroku-prebuild, heroku-build (falling back to build if heroku-build does not exist), heroku-postbuild.

Process types

If a start script is detected in package.json, the default process type for the build will be set to pnpm start.

pnpm version selection

This buildpack assumes that pnpm was installed by another buildpack, like heroku/nodejs-corepack. Check out heroku/nodejs-corepack to learn about how it selects versions.

Usage

To build an app locally into an OCI Image with this buildpack, use the pack command from Cloud Native Buildpacks using heroku/nodejs-engine, heroku/nodejs-corepack, and this buildpack:

pack build example-app-image --buildpack heroku/nodejs-engine --buildpack heroku/nodejs-corepack --buildpack heroku/nodejs-pnpm-install --path /some/example-app

Alternatively, use the heroku/builder:24 builder, which includes the above buildpacks:

pack build example-app-image --builder heroku/builder:24 --path /some/example-app

Build Plan

Provides

Name Description
node_modules Allows other buildpacks to depend on the Node modules provided by this buildpack.
node_build_scripts Allows other buildpacks to depend on the build script execution behavior provided by this buildpack.

Requires

Name Description
node To execute pnpm a Node.js runtime is required. It can be provided by the heroku/nodejs-engine buildpack.
pnpm To install node modules, the pnpm package manager is required. It can be provided by the heroku/nodejs-corepack buildpack.
node_modules This is not a strict requirement of the buildpack. Requiring node_modules ensures that this buildpack can be used even when no other buildpack requires node_modules.
node_build_scripts This is not a strict requirement of the buildpack. Requiring node_build_scripts ensures that this buildpack will perform build script execution even when no other buildpack requires node_build_scripts.

Build Plan Metadata Schemas

node_build_scripts
Example
[[requires]]
name = "node_build_scripts"

[requires.metadata]
enabled = false # this will prevent build scripts from running

Additional Info

For development, dependencies, contribution, license and other info, please refer to the root README.md.