Skip to content

feat: Support devEngines.packageManager#12388

Open
lachieh wants to merge 5 commits intovercel:mainfrom
lachieh:feat/support-devengines-packagemanager
Open

feat: Support devEngines.packageManager#12388
lachieh wants to merge 5 commits intovercel:mainfrom
lachieh:feat/support-devengines-packagemanager

Conversation

@lachieh
Copy link
Copy Markdown

@lachieh lachieh commented Mar 18, 2026

When the top-level packageManager field is missing from package.json, Turborepo now falls back to reading devEngines.packageManager.name (and optionally .version) to determine the package manager. This aligns with the Node.js ecosystem standard adopted by Corepack and npm.

The fallback chain is: packageManager → devEngines.packageManager → lockfile detection.

Closes #10845

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 18, 2026

@lachieh is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@lachieh lachieh marked this pull request as ready for review March 22, 2026 06:05
@lachieh lachieh requested a review from a team as a code owner March 22, 2026 06:05
@lachieh lachieh requested review from tknickman and removed request for a team March 22, 2026 06:05
@lachieh lachieh changed the title feat: Support devEngines.packageManager feat: Support devEngines.packageManager Mar 22, 2026
@lachieh lachieh force-pushed the feat/support-devengines-packagemanager branch from ef8b764 to 84fed15 Compare March 22, 2026 06:06
@lachieh lachieh force-pushed the feat/support-devengines-packagemanager branch from 84fed15 to 39938ec Compare March 23, 2026 23:33
lachieh and others added 5 commits March 27, 2026 16:01
…ager`

When the top-level `packageManager` field is missing from package.json,
Turborepo now falls back to reading `devEngines.packageManager.name`
(and optionally `.version`) to determine the package manager. This aligns
with the Node.js ecosystem standard adopted by Corepack and npm.

The fallback chain is: packageManager → devEngines.packageManager → lockfile detection.

Closes vercel#10845

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…etectors

Reuse YarnDetector::detect_berry_or_yarn and PnpmDetector::detect_pnpm6_or_pnpm
instead of duplicating version boundary logic. Construct a synthetic semver from
the extracted major version to pass to the existing detector methods.

Also remove unnecessary else block in read_package_manager.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Unit tests:
- Unparseable version ("latest") with no lockfile → error
- Empty version string with no lockfile → error
- No version, no lockfile → error
- No version with pnpm-lock.yaml present → lockfile fallback
- read_or_detect_package_manager public API with devEngines

Integration tests:
- devEngines npm detection via turbo config
- devEngines pnpm9 detection via turbo config
- devEngines yarn berry detection via turbo config
- Top-level packageManager takes precedence over devEngines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Strip common range prefixes (^, >=, ~, etc.) before extracting the
major version from devEngines.packageManager.version. Previously,
versions like "^9.0.0" or ">=4.0.0" would silently fall through to
lockfile detection instead of correctly identifying the major version.

Also adds a length cap (10 chars) on digit extraction to prevent
theoretical unbounded allocation from adversarial input.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The npm spec allows devEngines.packageManager to be either an object or
an array of objects (ordered preference). Handle both forms by picking
the first array entry with a valid name field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lachieh lachieh force-pushed the feat/support-devengines-packagemanager branch from 035a7ad to c4a7dde Compare March 27, 2026 20:01
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.

Support devEngines.packageManager as an alternative to packageManager

1 participant