fix(bun): respect loader returned from load hook + feat(bun): support plugin.bun.loader for per-plugin loader resolution#601
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (4)
📝 WalkthroughWalkthroughAdds LoadResult and unwrapLoader; Bun adapter records load-hook-provided loader and active plugin, then selects loader with precedence: load-hook override → plugin.bun.loader (possibly invoked) → original loader → guessLoader(id). Tests cover virtual-module loader resolution and precedence. ChangesBun Loader Override Support
Sequence DiagramsequenceDiagram
participant Plugin as Plugin.load hook
participant Adapter as Bun adapter (processLoadTransform)
participant Unwrap as unwrapLoader
Plugin->>Adapter: return { code, loader? } | or string code
Adapter->>Adapter: record loaderOverride, activePlugin
Adapter->>Unwrap: call unwrapLoader(plugin.bun.loader, code, id)
Unwrap-->>Adapter: resolved plugin loader
Adapter-->>Caller: return contents and chosen loader (loaderOverride || pluginLoader || originalLoader || guessLoader)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/bun/index.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. src/bun/utils.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. src/types.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.
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 |
Use the loader returned by object load results before falling back to Bun's provided loader or guessed loader.
d6d0846 to
cc573f1
Compare
commit: |
|
@sxzz I've updated the commit message and fixed the merge conflict, lmk if there's any more feedback :) |
Add `loader` to the `bun` plugin option block, accepting either a `Loader` literal or `(code, id) => Loader` function, mirroring the existing `plugin.esbuild.loader` API.
I am volunteering and working on getting a bun plugin for TanStack/router and found this bug.
loadhook cannot override the inferredLoader#600Summary by CodeRabbit
New Features
Tests