-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(turborepo-lockfiles): Update bun.lock support to match Bun's current implementation #10729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Someone is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
// Workspace dependencies are referenced by their relative path | ||
// e.g., "@repo/ui": "packages/ui" | ||
// We need to check if this path exists in our workspaces | ||
if !version.contains('/') || version.starts_with('^') || version.starts_with('~') || version.starts_with('=') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workspace package paths are allowed to not have a /
in them though it is uncommon
.iter() | ||
.map(|ident| { | ||
// Extract package name from ident (e.g., "foo@1.0.0" -> "foo") | ||
ident.split('@').next().unwrap_or(ident).to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not correctly handle scoped package names
…rent implementation Updates Turborepo's bun.lock parser to support features from Bun's latest lockfile format, addressing compatibility gaps and adding missing functionality. ## What? - Add LockfileVersion enum for v0/v1 format handling - Fix global_change() to detect version changes (was only checking package manager) - Add support for new lockfile fields: trustedDependencies, overrides, catalog/catalogs - Implement platform-specific constraints (os/cpu fields) - Add v1 workspace optimizations (reduces redundant package entries) - Add bun_global_change() standalone function for API consistency ## Why? The existing implementation had several gaps: - Cache invalidation could fail when lockfile versions changed - New Bun lockfile fields were silently ignored - V1 optimizations were not implemented - Platform constraints were not parsed ## How? - Catalog resolution via resolve_catalog_version() method - Override support via apply_overrides() method - Negatable enum for platform constraints - Version-aware workspace resolution - Comprehensive subgraph filtering ## Testing Ran tests with: ```bash cargo test -p turborepo-lockfiles ``` - Added 43 new tests (72 total Bun tests, up from 29) - All 238 package manager tests pass - Test coverage includes: version detection, catalogs, overrides, v1 workspaces, platform constraints, integration scenarios ## Notes - Based on Bun's src/install/lockfile/bun.lock.zig - Follows existing patterns from npm/pnpm/yarn implementations - Some features (trusted deps, platform filtering) are parsed but not actively used 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
@Jarred-Sumner Any updates or timelines on this? Seems like turborepo with bun catalogs just triggers fan-out tasks whenever there is a change to the lock file (e.g. adding any package, local workspace or external). |
Description
Updates Turborepo's bun.lock parser to better align with Bun's current lockfile format implementation. This addresses version detection issues, adds support for new lockfile fields, and implements v1 optimizations.
Testing Instructions
Test Results
Background
While investigating Turborepo's bun.lock support against Bun's implementation (
src/install/lockfile/bun.lock.zig
), I identified several gaps:global_change()
only detected package manager changes, not lockfile version changesChanges
Core Fixes
Version Detection
LockfileVersion
enum for v0/v1 handlingglobal_change()
to detect version changes (prevents incorrect cache hits)bun_global_change()
for API consistency with other package managersNew Field Support
Platform Constraints
Feature Implementations
resolve_catalog_version()
methodapply_overrides()
methodNegatable
type with serde supportResolution Order
The implementation follows this precedence: catalog → override → patch
Areas of Uncertainty
I want to be transparent about areas where I'm less confident or made assumptions:
V1 Behavior Beyond Workspaces: While I implemented the workspace optimization mentioned in Bun's source, there may be other v1-specific behaviors I'm not aware of.
Trusted Dependencies: I parse and filter these, but I'm unsure if Turborepo needs to actually use this information for any security/installation decisions.
Platform Constraint Application: The
Negatable::allows()
method is implemented but unused. I'm not sure where in Turborepo's architecture platform filtering should actually occur.Catalog Precedence: I assumed catalogs should be resolved before overrides based on the code structure, but this precedence isn't explicitly documented.
Error Handling: Some edge cases (like circular workspace dependencies or conflicting overrides) may not be handled optimally.
Potential Issues
Performance: The catalog resolution adds an extra lookup step during package resolution. For large monorepos with many catalog references, this could impact performance.
Backward Compatibility: While I've maintained compatibility with existing lockfiles, the changes to
global_change()
will cause cache invalidation for projects upgrading Turborepo.Incomplete Platform Support: The platform constraints are parsed but not actively used for filtering during dependency resolution.
Questions for Reviewers
UnsupportedVersion
error be recoverable or fatal?Known Limitations
Negatable::allows()
method for platform matching is unused (added for completeness)Additional Context
This is a draft PR as I would appreciate feedback on the implementation approach, particularly in areas where I made assumptions about intended behavior.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com