Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@vercel/build-utils

vercel3.9mApache-2.010.6.0TypeScript support: included

null

readme

Vercel

Develop. Preview. Ship.

Documentation · Changelog · Templates · CLI


Vercel

Vercel’s Frontend Cloud provides the developer experience and infrastructure to build, scale, and secure a faster, more personalized Web.

Deploy

Get started by importing a project, choosing a template, or using the Vercel CLI. Then, git push to deploy.

Documentation

For details on how to use Vercel, check out our documentation.

Contributing

This project uses pnpm to install dependencies and run scripts.

You can use the vercel script to run local changes as if you were invoking Vercel CLI. For example, vercel deploy --cwd=/path/to/project could be run with local changes with pnpm vercel deploy --cwd=/path/to/project.

When contributing to this repository, please first discuss the change you wish to make via Vercel Community with the owners of this repository before submitting a Pull Request.

Please read our Code of Conduct and follow it in all your interactions with the project.

Local development

This project is configured in a monorepo, where one repository contains multiple npm packages. Dependencies are installed and managed with pnpm, not npm CLI.

To get started, execute the following:

git clone https://github.com/vercel/vercel
cd vercel
corepack enable
pnpm install
pnpm build
pnpm lint
pnpm test-unit

Make sure all the tests pass before making changes.

Running Vercel CLI Changes

You can use pnpm vercel from the cli package to invoke Vercel CLI with local changes:

cd ./packages/cli
pnpm vercel <cli-commands...>

See CLI Local Development for more details.

Verifying your change

Once you are done with your changes (we even suggest doing it along the way), make sure all the tests still pass by running:

pnpm test-unit

from the root of the project.

If any test fails, make sure to fix it along with your changes. See Interpreting test errors for more information about how the tests are executed, especially the integration tests.

Pull Request Process

Once you are confident that your changes work properly, open a pull request on the main repository.

The pull request will be reviewed by the maintainers and the tests will be checked by our continuous integration platform.

Interpreting test errors

There are 2 kinds of tests in this repository – Unit tests and Integration tests.

Unit tests are run locally with jest and execute quickly because they are testing the smallest units of code.

Integration tests

Integration tests create deployments to your Vercel account using the test project name. After each test is deployed, the probes key is used to check if the response is the expected value. If the value doesn't match, you'll see a message explaining the difference. If the deployment failed to build, you'll see a more generic message like the following:

[Error: Fetched page https://test-8ashcdlew.vercel.app/root.js does not contain hello Root!. Instead it contains An error occurred with this application.

    NO_STATUS_CODE_FRO Response headers:
       cache-control=s-maxage=0
      connection=close
      content-type=text/plain; charset=utf-8
      date=Wed, 19 Jun 2019 18:01:37 GMT
      server=now
      strict-transport-security=max-age=63072000
      transfer-encoding=chunked
      x-now-id=iad1:hgtzj-1560967297876-44ae12559f95
      x-now-trace=iad1]

In such cases, you can visit the URL of the failed deployment and append /_logs to see the build error. In the case above, that would be https://test-8ashcdlew.vercel.app/_logs

The logs of this deployment will contain the actual error which may help you to understand what went wrong.

Running integration tests locally

While running the full integration suite locally is not recommended, it's sometimes useful to isolate a failing test by running it on your machine. To do so, you'll need to ensure you have the appropriate credentials sourced in your shell:

  1. Create an access token. Follow the instructions here https://vercel.com/docs/rest-api#creating-an-access-token. Ensure the token scope is for your personal account.
  2. Grab the team ID from the Vercel dashboard at https://vercel.com/<MY-TEAM>/~/settings.
  3. Source these into your shell rc file: echo 'export VERCEL_TOKEN=<MY-TOKEN> VERCEL_TEAM_ID=<MY-TEAM-ID>' >> ~/.zshrc

From there, you should be able to trigger an integration test. Choose one that's already isolated to check that things work:

cd packages/next

Run the test:

pnpm test test/fixtures/00-server-build/index.test.js

[!NOTE] If you receive a 401 status code while fetching the deployment, you need to disable Deployment Protection on the project.

@vercel/nft

Some of the Builders use @vercel/nft to tree-shake files before deployment. If you suspect an error with this tree-shaking mechanism, you can create the following script in your project:

const { nodeFileTrace } = require('@vercel/nft');
nodeFileTrace(['path/to/entrypoint.js'], {
  ts: true,
  mixedModules: true,
})
  .then(o => console.log(o.fileList))
  .then(e => console.error(e));

When you run this script, you'll see all the imported files. If files are missing, the bug is in @vercel/nft and not the Builder.

Deploy a Builder with existing project

Sometimes you want to test changes to a Builder against an existing project, maybe with vercel dev or actual deployment. You can avoid publishing every Builder change to npm by uploading the Builder as a tarball.

  1. Change directory to the desired Builder cd ./packages/node
  2. Run pnpm build to compile typescript and other build steps
  3. Run npm pack to create a tarball file
  4. Run vercel *.tgz to upload the tarball file and get a URL
  5. Edit any existing vercel.json project and replace use with the URL
  6. Run vercel or vercel dev to deploy with the experimental Builder

Reference

changelog

@vercel/build-utils

10.6.0

Minor Changes

  • provide a more verbose error when package.json is not valid (#13346)

  • Allow configuring functions architecture via the vercel.json configuration (#13344)

10.5.1

Patch Changes

  • Display warning when yarn dynamic require error may happen (#13143)

  • [build-utils] increase max memory limit (#13162)

10.5.0

Minor Changes

  • Disable yarn global cache before installs so build cache caches deps (#13144)

10.4.0

Minor Changes

  • Expose pnpm6 within the detected package manager path for future versions of the build container (#13132)

10.3.2

Patch Changes

  • Add support for expire values in Next.js prerender manifest (#13087)

  • Detect yarn version from lockfile version (#13118)

10.3.1

Patch Changes

  • Parse yarn.lock file version (#13114)

  • [env-vars] expose VERCEL_DEPLOYMENT_ID as NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID (#13115)

  • Fix vitest-e2e glob to include integration.test.ts (#13097)

10.3.0

Minor Changes

  • Delay pnpm@10 preferred date (#13100)

Patch Changes

10.2.0

Minor Changes

  • Detect v9 pnpm lock files as pnpm 10 for new projects (#13072)

Patch Changes

  • Improve build log messages surrounding pnpm 10 (#13088)

  • [build-utils] extract checkIfAlreadyInstalled helper to clarify intent (#13060)

  • Allow pnpm 10 to use package.json#packageManager without an engines error (#13083)

10.1.0

Minor Changes

  • [envs] add VERCEL_TARGET_ENV to prefixed env vars (#13069)

10.0.1

Patch Changes

  • [build-utils] Move runNpmInstallSema closer to where it's used (#13061)

  • [build-utils] extract getInstallCommandForPackageManager to module scope (#13058)

  • [build-utils] remove redundant sema release (#13059)

  • Revert support pnpm 10 (#13064)

10.0.0

Major Changes

  • Detect v9 pnpm lockfiles as pnpm 10 generated (#12852)

9.3.1

Patch Changes

  • [build-utils] extract install command specific logic into helper (#13049)

  • [build-utils] remove dead node 16 check (#13047)

9.3.0

Minor Changes

  • Support process tracing (#12894)

9.2.1

Patch Changes

  • Add tracer utility to @vercel/build-utils (#13013)

9.2.0

Minor Changes

  • Add .yarn/cache to build cache (#12961)

9.1.1

Patch Changes

  • [cli] shift node 16 deprecation date to 2025-02-03 (#12981)

9.1.0

Minor Changes

  • Add useWebApi property to NodejsLambda class (#12873)

  • [build-utils] convert NodeVersion to class and add state getter (#12883) [ruby] convert RubyVersion to class and add state getter

9.0.1

Patch Changes

  • Revert build utils refactor (#12818)

9.0.0

Major Changes

  • Change getPathOverrideForPackageManager() to use detectedLockfile argument (#12813)

Patch Changes

  • Refactor build-util usage to reuse detected lockfile (#12813)

  • add support for images.qualities (#12813)

8.8.0

Minor Changes

  • Add bun detection using bun.lock (#12740)

8.7.0

Minor Changes

  • Support splitting archive deployments in parts. (#12671)

8.6.0

Minor Changes

  • Add support for NOW_EPHEMERAL_FILES_S3_URL, NOW_FILES_CLOUDFRONT_URL and NOW_FILES_S3_URL environment variables (#12643)

8.5.0

Minor Changes

  • Remove VERCEL_ALLOW_NODEJS22 env var check (#12614)

8.4.12

Patch Changes

  • Support allowHeader from Next.js for filtering request headers during revalidation (#12420)

8.4.11

Patch Changes

  • Improve parsing of turbo.json (#12266)

  • Fix corepack packageManager detection on monorepos (#12258)

8.4.10

Patch Changes

  • Parse turbo.json as json5 (#12259)

8.4.9

Patch Changes

  • Fix special version specifier handling for turbo (#12249)

8.4.8

Patch Changes

  • Revert "[build-utils] Fix corepack packageManager detection on monorepos" (#12242)

8.4.7

Patch Changes

  • Disable corepack when Turborepo does not support COREPACK_HOME (#12211)

  • Fix corepack packageManager detection on monorepos (#12219)

8.4.6

Patch Changes

  • add support for images.localPatterns (#12195)

8.4.5

Patch Changes

  • [build-utils] add types for images.remotePatterns.search to vercel.json (#12158)

8.4.4

Patch Changes

  • Allow Node.js v22 behind env var feature flag (#12159)

8.4.3

Patch Changes

  • Introduce new chain configuration types for Partial Prerendering (#12063)

8.4.2

Patch Changes

  • Revert "Revert "Revert "Fix corepack packageManager detection on monorepos""" (#12099)

8.4.1

Patch Changes

  • Revert "Revert "Fix corepack packageManager detection on monorepos"" (#11871)

8.4.0

Minor Changes

  • Change warnings to errors in invalid corepack package manager states (#12062)

8.3.9

Patch Changes

  • Provide help when users get ERR_PNPM_UNSUPPORTED_ENGINE errors without corepack (#12034)

  • Fix package-manager-warning-1 to happen only happen in correct cases (#12050)

8.3.8

Patch Changes

  • Limit package.json#packageManager parsing to concrete versions (#12025)

  • Catch PNPM_UNSUPPORTED_ENGINE when corepack is enabled and throw a more helpful error (#12017)

8.3.7

Patch Changes

  • Revert "Revert "warn on mismatched corepack and detected package managers"" (#11887)

8.3.6

Patch Changes

  • Remove implicit reliance on @types/glob for downstream consumers (#11914)

8.3.5

Patch Changes

  • Revert "warn on mismatched corepack and detected package managers" (#11879)

8.3.4

Patch Changes

  • Revert "Fix corepack packageManager detection on monorepos" (#11865)

8.3.3

Patch Changes

  • Fix corepack packageManager detection on monorepos (#11811)

8.3.2

Patch Changes

  • reject mismatched corepack and detected package managers (#11603)

8.3.1

Patch Changes

  • Add build callback handling (#11807)

8.3.0

Minor Changes

  • Adds the ability for builders to define a diagnostics step that is called after the build operation is done. (#11653) Implements the diagnostics step in the next builder.

Patch Changes

  • Add resolved node version range to warning message (#11742)

8.2.2

Patch Changes

  • Change node 16.x EOL for Vercel (#11704)

  • Improve error message and refactor (#11706)

  • [built-utils] Handle case of not having lockfile when corepack is enabled (#11697)

8.2.1

Patch Changes

  • [node] update node@16 deprecation day (#11671)

8.2.0

Minor Changes

  • fix corepack detection for package manager version determination (#11596)

Patch Changes

  • Fix triggering of ignored project settings node version warning (#11550)

8.1.3

Patch Changes

  • [build-utils] log more around package manager detection (#11594)

8.1.2

Patch Changes

  • add log to package manager version detection (#11592)

8.1.1

Patch Changes

  • [build-utils] pnpm lockfile testing and fixing (#11591)

8.1.0

Minor Changes

  • Update pnpm version detection logic (#11445) Add support for pnpm 9

8.0.0

Major Changes

  • Remove legacy avoidTopLevelInstall logic (#11513)

Patch Changes

  • [build-utils] Add VERCEL_PROJECT_PRODUCTION_URL framework env var prefix (#11506)

7.12.0

Minor Changes

7.11.0

Minor Changes

  • Add getOsRelease() and getProvidedRuntime() functions (#11370)

7.10.0

Minor Changes

  • Allow environment variables to be specified for EdgeFunction (#11029)

7.9.1

Patch Changes

  • Export getSupportedNodeVersion (#11277)

7.9.0

Minor Changes

  • Add base parameter to scanParentDirs() (#11261)

7.8.0

Minor Changes

  • Remove VERCEL_ENABLE_NPM_DEFAULT env var check (#11242)

Patch Changes

  • Rename variants to flags and remove legacy flags (#11121)

7.7.1

Patch Changes

  • [build-utils] increase max memory limit (#11209)

7.7.0

Minor Changes

  • Revert "Revert "Default ruby to only currently supported version (3.2.0)"" (#11137)

7.6.0

Minor Changes

  • Revert "Default ruby to only currently supported version (3.2.0)" (#11135)

  • Mark flags as deprecated and replace them with variants (#11098)

  • [build-utils] change default package manager when no lockfile detected from yarn to npm (gated behind feature flag) (#11131)

Patch Changes

  • Update internal type for variants (#11111)

7.5.1

Patch Changes

  • Add experimental field to Lambda and size to FileFsRef output (#11059)

7.5.0

Minor Changes

  • Deprecate EdgeFunction#name property (#11010)

7.4.1

Patch Changes

  • Extend Node v16 discontinue date to 2024-06-15 (#10967)

7.4.0

Minor Changes

  • Adds new helper getPathForPackageManager() (#10918)

7.3.0

Minor Changes

  • [cli] add --deprecated option to vc project ls command (#10919)

7.2.5

Patch Changes

  • Remove Node.js v20 env var check (#10834)

7.2.4

Patch Changes

  • Select Node.js version based on what's available in build-container (#10822)

7.2.3

Patch Changes

  • Add experimental flag to allow Node.js v20 (#10802)

7.2.2

Patch Changes

  • [cli] Update bun detection and add tests for projects with both bunlock binary and yarn.lock text files (#10583)

7.2.1

Patch Changes

7.2.0

Minor Changes

  • Add new optional prerender field: experimentalStreamingLambdaPath (#10476)

  • [build-utils] Add zero config detection for bun package manager (#10486)

Patch Changes

  • add experimentalBypassFor field to Prerender (#10481)

7.1.1

Patch Changes

  • add descriptions to NodeVersion properties (#10403)

  • Updated semver dependency (#10411)

7.1.0

Minor Changes

  • Support serverless function architecture (#10392)

7.0.0

Major Changes

  • BREAKING CHANGE: Drop Node.js 14, bump minimum to Node.js 16 (#10369)

6.8.3

Patch Changes

  • Fix getPrefixedEnvVars() to handle VERCEL_BRANCH_URL (#10315)

6.8.2

Patch Changes

  • Push back nodejs16.x discontinue date to 2024-02-06 (#10209)

6.8.1

Patch Changes

  • Revert "[build-utils] Allow file-ref sema to be controlled through env flag" (#10167)

6.8.0

Minor Changes

  • Add getNodeBinPaths() and traverseUpDirectories() functions (#10150)

6.7.5

Patch Changes

6.7.4

Patch Changes

  • Remove usage of env from Edge Functions and Middleware (#10018)

6.7.3

Patch Changes

  • Deprecate Node.js 14.x and 16.x with warning (#9976)