fix(bundler): resolve devtools bridge and UI assets from package root#768
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces dynamic package-relative path resolution to the devtools plugin. A new ChangesPath Resolution Infrastructure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Bundle Size Analysis
|
🔗 Linked issue
Related to #764
❓ Type of change
📚 Description
The devtools Vite plugin resolved its bridge script and UI assets relative to
import.meta.url, assuming the code runs fromdist/vite.mjs. unbuild code-splits the plugin intodist/shared/bundler.*.mjs, so at runtimenew URL('..', import.meta.url)pointed atdist/instead of the package root. That madebridgePathresolve todist/dist/devtools/bridge.mjs(served the[unhead devtools] bridge not builtwarning) anddevtoolsUiDirresolve todist/shared/devtools-ui(blank devtools panel).vite.tsnow finds the package root by walking up to the nearestpackage.json, so paths resolve correctly regardless of which chunk the code lands in (dist/vite.mjs,dist/shared/*.mjs, or stubbedsrc). The unhead version lookup had the same fragility (it read a nestednode_modules/unhead/package.jsonthat does not exist under hoisted/pnpm installs); it now resolves theunheadentry viacreateRequireand walks up to its package root.Verified against the reported setup (
@unhead/vue+@vitejs/devtools,vite dev):/@unhead/bridge.mjsserves real bridge code, the/__unhead/panel returns 200, and the bridge reports the correct unhead version. All 81 bundler tests pass.Summary by CodeRabbit