Skip to content

fix: Treat npm: alias dependencies as external, not workspace references#12061

Merged
anthonyshew merged 1 commit into
mainfrom
shew/fix-8989
Feb 28, 2026
Merged

fix: Treat npm: alias dependencies as external, not workspace references#12061
anthonyshew merged 1 commit into
mainfrom
shew/fix-8989

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

Fixes #8989

  • When a dependency uses the npm: alias syntax (e.g. "buffer": "npm:buffer@6.0.3"), turborepo incorrectly resolved it to a workspace of the same name instead of the npm registry package. The npm:<pkg>@<version> format explicitly targets the npm registry and should never match a workspace.

Root cause

DependencyVersion::new("npm:buffer@6.0.3") splits into protocol="npm" and version="buffer@6.0.3". Since npm is special-cased to not be treated as external (for transparent workspace support), the code falls through to semver comparison. "buffer@6.0.3" fails to parse as a semver range, and the backwards-compatibility fallback treats parse failures as internal matches.

Fix

Added is_npm_alias() to detect the npm:<pkg>@<version> alias format (including scoped packages like npm:@scope/pkg@^1.0.0). Aliased npm dependencies are always treated as external since they explicitly target the npm registry. This is distinct from plain npm:^1.0.0 ranges which still participate in transparent workspace resolution.

Testing

To understand the fix, the test_is_npm_alias and test_matches_workspace_package ("handles npm alias with matching workspace name") test cases in dep_splitter.rs are the most relevant. A berry lockfile test (test_npm_alias_does_not_resolve_to_workspace) verifies the lockfile resolution and pruning paths. A berry-npm-alias fixture was added to lockfile-tests/fixtures/ reproducing the exact scenario from the issue.

When a dependency uses the npm: alias syntax (e.g. "buffer": "npm:buffer@6.0.3"),
turborepo incorrectly resolved it to a workspace of the same name. The alias
format npm:<pkg>@<version> explicitly targets the npm registry, so it should
never match a workspace package.

Closes #8989
@anthonyshew anthonyshew requested a review from a team as a code owner February 28, 2026 04:53
@anthonyshew anthonyshew requested review from tknickman and removed request for a team February 28, 2026 04:53
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-designsystem-docs Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-gatsby-web Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-kitchensink-blog Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-nonmonorepo Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-svelte-web Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Feb 28, 2026 4:53am
examples-vite-web Ready Ready Preview, Comment, Open in v0 Feb 28, 2026 4:53am
turbo-site Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
turborepo-agents Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am
turborepo-test-coverage Building Building Preview, Comment, Open in v0 Feb 28, 2026 4:53am

@anthonyshew anthonyshew changed the title fix: Treat npm: alias dependencies as external, not workspace references fix: Treat npm: alias dependencies as external, not workspace references Feb 28, 2026
@anthonyshew anthonyshew enabled auto-merge (squash) February 28, 2026 05:07
@anthonyshew anthonyshew disabled auto-merge February 28, 2026 05:11
@anthonyshew anthonyshew enabled auto-merge (squash) February 28, 2026 05:11
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Metric Coverage
Lines 81.41%
Functions 53.29%
Branches 0.00%

View full report

@anthonyshew anthonyshew merged commit b179cb8 into main Feb 28, 2026
113 of 116 checks passed
@anthonyshew anthonyshew deleted the shew/fix-8989 branch February 28, 2026 05:14
github-actions Bot added a commit that referenced this pull request Feb 28, 2026
## Release v2.8.13-canary.8

Versioned docs: https://v2-8-13-canary-8.turborepo.dev

### Changes

- fix: Exclude peer dependencies from workspace external dep resolution
(#12050) (`3a75547`)
- test: Port all 15 workspace-configs prysk tests to Rust (#12058)
(`55442be`)
- release(turborepo): 2.8.13-canary.7 (#12060) (`495afdc`)
- perf: Stream file contents during hashing to lower memory usage
(#12059) (`f03cdce`)
- fix: Treat `npm: alias` dependencies as external, not workspace
references (#12061) (`b179cb8`)
- test: Port 18 more prysk tests to Rust (other/ +
lockfile-aware-caching/) (#12062) (`7887af2`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
github-actions Bot added a commit that referenced this pull request Mar 2, 2026
## Release v2.8.13-canary.9

Versioned docs: https://v2-8-13-canary-9.turborepo.dev

### Changes

- fix: Treat `npm: alias` dependencies as external, not workspace
references (#12061) (`b179cb8`)
- test: Port 18 more prysk tests to Rust (other/ +
lockfile-aware-caching/) (#12062) (`7887af2`)
- release(turborepo): 2.8.13-canary.8 (#12063) (`2a5522a`)
- fix: Preserve file: protocol entries in pruned yarn v1 lockfile
(#12064) (`ae5c1a1`)
- perf: Use stack-allocated OidHash in FileHashes and skip expanded
hashes on normal runs (#12065) (`677b248`)
- test: Port all 8 find-turbo prysk tests to Rust (#12066) (`f827fca`)
- fix: Support pnpm per-workspace lockfiles in turbo prune (#12067)
(`23d047d`)
- test: Port final 2 prysk tests to Rust (100% complete) (#12068)
(`6d7e057`)
- fix: Resolve Berry prune failure when resolutions contain patch
overrides (#12069) (`6fe3c5e`)
- test: Add lockfile fixture for yarn berry resolution pruning (issue
#2791) (#12071) (`6cc1654`)
- chore: Remove prysk test framework entirely (#12070) (`ed2d05a`)
- refactor: Clean up test infrastructure and eliminate duplication
(#12072) (`338911d`)
- fix: Retain injected workspace package entries during pnpm lockfile
pruning (#12073) (`acbe869`)
- ci: Exclude turborepo-lsp and turborepo-schema-gen from test builds
(#12075) (`4ce12e2`)
- refactor: Clean up test infrastructure + improve test quality (#12074)
(`4571f2b`)
- ci: Remove redundant cargo build from coverage job (#12077)
(`3c9bbe2`)
- perf: Speed up lockfile test suite (#12078) (`20024df`)
- ci: Remove integration test serialization (#12079) (`24d7c02`)
- fix: Preserve `file:` and `link:` protocol entries in pruned bun
lockfile (#12076) (`2635d9a`)
- fix: Stop running unnecessary npm install in engines tests (#12081)
(`24e4905`)
- test: Add lockfile fixture for pnpm v9 injected workspace deps (issue
#8243) (#12082) (`4d4929b`)
- fix: Filter orphaned Yarn packageExtensions entries during lockfile
pruning (#12084) (`68eb223`)
- fix: Align experimentalObservability on object maps rather than arrays
(#12089) (`9b9d1e4`)
- examples: Upgrade with-react-native-web example to use latest versions
(#12085) (`980ca43`)
- fix: duplicate /signup? in Vercel URL (#12088) (`e865b51`)
- ci: Deduplicate Rust test compilation with nextest archive (#12083)
(`962cf39`)
- fix: Prevent yarn integration tests from hanging on corepack prompts
(#12090) (`29b0da7`)
- fix: Prevent turbo dev from hanging when daemon file watching fails
(#12091) (`b0d2f62`)
- ci: Skip pnpm install for Rust test jobs (#12092) (`ebd137f`)
- perf: Optimize npm lockfile parser (#12093) (`e4b4a66`)
- chore: Trim unused dependency features for faster compilation (#12094)
(`03b79e0`)
- fix: Prevent lockfile-aware yarn test from hanging on corepack
downloads (#12095) (`bf516e4`)
- fix: Exclude turborepo-repository from JS smoke test in release
workflow (#12097) (`fecc400`)

---------

Co-authored-by: Turbobot <turbobot@vercel.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.

Yarn 4: Respect enableTransparentWorkspaces: false when resolving workspace dependencies

1 participant