fix(resolve): #5914 — compilePackages wildcard misses bun's flat-store-only deps#5915
fix(resolve): #5914 — compilePackages wildcard misses bun's flat-store-only deps#5915proggeramlug wants to merge 3 commits into
Conversation
…at-store-only deps `enumerate_installed_packages` (backing perry.compilePackages's "*" / "@scope/*" wildcard expansion) only walked top-level node_modules/<name> entries plus npm's own nested node_modules dedup layout. Bun's flat/isolated linker only symlinks packages that are a direct dependency of some workspace package at the top level — purely transitive dependencies live only inside node_modules/.bun/<pkg>@<version>/node_modules/<pkg>, which the existing walker correctly (but incompletely, for this case) skips as a dotdir. On a real bun install this silently drops dozens of installed, importable packages from the wildcard (confirmed via sst/opencode: ajv, openai, cliui, escalade, yargs-parser, and ~60 others), which then fail with "still routed to runtime JavaScript... not in perry.compilePackages" even with compilePackages: ["*"] set. Fix: also walk node_modules/.bun/*/node_modules/* (reusing the existing collect_packages_in_node_modules walker, since bun's per-package node_modules dir has the identical shape).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughExtends ChangesBun Flat-Store Package Discovery
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…e, not just the nearest node_modules The first pass only checked the *nearest* node_modules dir found by find_node_modules for a .bun subdirectory. In a real bun workspace/monorepo, .bun typically lives ONLY at the true root, while a workspace member commonly has its OWN nearer (bun-created, .bun-less) node_modules holding just its first-party sibling-package symlinks — find_node_modules stops there and never reaches the root. Confirmed against sst/opencode: compiling packages/opencode/src/index.ts as project_root (a workspace member) previously still expanded the "*" wildcard to only 167 packages (all it could see was its own node_modules, no .bun); after walking every ancestor's node_modules/.bun independently, it correctly expands to 1927 packages and the "still routed to runtime JavaScript" hint for ajv/openai/cliui/etc. disappears entirely. Added a regression test with a synthetic workspace member whose own node_modules has no .bun, only the root's does.
|
Pushed a followup fix: the first pass only checked the nearest node_modules for |
… cap) resolve/tests.rs was already ~1939 lines; appending the two PerryTS#5914 regression tests pushed it past the workspace's 2000-line file-size lint gate. Move them to a new resolve/bun_store_tests.rs sibling module, matching the existing pattern of splitting resolve.rs's concerns into focused files (native_library.rs, tsconfig_paths.rs). No behavior change.
Fixes #5914.
Problem
enumerate_installed_packages(which materializesperry.compilePackages's"*"/"@scope/*"wildcard into concrete package names, per #3527) only walks top-levelnode_modules/<name>entries plus npm's own nestednode_modulesdedup layout.Bun's flat/isolated linker only creates top-level symlinks for packages that are a direct dependency of some workspace package. Purely-transitive dependencies live only inside
node_modules/.bun/<pkg>@<version>/node_modules/<pkg>(and the scoped@scope+pkg@<version>variant) — the existing walker correctly skips.bunas a dotdir (it's bun's internal store, not a package), but that means those packages are invisible to the wildcard even though they're genuinely installed and importable.Confirmed via a real
bun installonsst/opencode: ~65 packages (ajv,openai,cliui,escalade,yargs-parser, …) have no top-levelnode_modules/<name>entry at all, only a.bun/-nested one. WithcompilePackages: ["*"]set, perry still reports them as "still routed to runtime JavaScript... not inperry.compilePackages", and the build hard-fails on any of them that's actually imported (V8 fallback is removed).Fix
Also walk
node_modules/.bun/*/node_modules/*when materializing the wildcard, reusing the existingcollect_packages_in_node_moduleswalker since bun's per-packagenode_modulesdirectory has the exact same shape as an ordinary one.Testing
Added
enumerate_installed_packages_finds_bun_flat_store_only_packages— lays out a syntheticnode_moduleswith a normal hoisted package plus bun-flat-store-only packages (both unscoped and scoped), asserts all three are found.cargo test -p perry enumerate_installed_packages_finds_bun_flat_store_only_packagespasses.🤖 Generated with Claude Code
Summary by CodeRabbit
.bun, including scoped packages.