Dashboardcraftbun pm pack reads workspace versions fr…

bun pm pack reads workspace versions from bun.lock, not package.json

Category: gotcha
Confidence: 0.90
ID: 019db1ee-c08c-739e-879e-d958e5d9f1a1
Project ID: e16af391-c497-4837-b681-c849a5514499
Cross-project: No
Recalled in other projects: 0
Source session: (none)
Created: 2026-07-28 10:15:42
Updated: 2026-07-28 10:15:42

Content

bun pm pack rewrites workspace:* specifiers to concrete versions at pack time, reading them from bun.lock — NOT from the workspace package.json. If craft bumps package.json but leaves bun.lock stale, published tarballs point at old versions (ETARGET on install). Fix in NpmTarget.patchBunLock (src/targets/npm.ts): regex-patch bun.lock per workspace path-key. CRITICAL regex gotcha: use [^{}]*? (not [\s\S]*?) to bound the match to the workspace's own block — [\s\S]*? walks past a versionless workspace's closing } and silently rewrites the NEXT workspace's version. Normalize \/ for Windows; escape regex chars (reuse escapeRegex from src/utils/filters.ts, don't duplicate). Only call when isWorkspace is true — otherwise non-workspace bun repos get a spurious 'lockfile out of sync' warning. Idempotent; uses safeFs.writeFileSync.

Move to: