Unify bundler plugins to esbuild-shaped Plugin API (#49) - #110
Draft
nounder wants to merge 1 commit into
Draft
Conversation
Adds src/bundler/Plugin.ts: bundler-agnostic onResolve/onLoad plugin
types modeled on esbuild's plugin API (no unplugin dependency).
Adapts TailwindPlugin.make() to return this generic Plugin instead of
a Bun-specific BunPlugin, and adds thin adapters to run it on any of
the three bundlers already in the codebase:
- bun/BunPlugin.toBunPlugin (pass-through, Bun's shape already matches)
- esbuild/EsbuildPlugin.toEsbuildPlugin (synthesizes defer())
- rolldown/RolldownPlugin.toRolldownPlugin (maps onResolve/onLoad onto
resolveId/load, synthesizes defer(), and emits CSS results as an
asset since Rolldown dropped native CSS bundling)
defer() emulation for esbuild/rolldown lives in
bundler/internal/DeferredLoad.ts, shared by both adapters.
Updates the tailwind package entrypoints (index.ts, plugin.ts) and the
examples to convert through BunPlugin.toBunPlugin explicitly.
Tests: unit tests for DeferredLoad's defer()/wrapLoad() semantics, plus
end-to-end tests building a real Tailwind CSS entrypoint through each
of Bun.build, esbuild.build, and rolldown.build via the new adapters.
Co-authored-by: Ralph Gutkowski <nounder@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49
Summary
Bundler-specific plugins (e.g. Bun Tailwind) are generalized to an esbuild-shaped plugin API shared across Bun, esbuild, and Rolldown — without taking an
unplugindependency.Changes
bundler/PluginwithonResolve/onLoad(+ Bun-styledefer)BunPlugin,EsbuildPlugin,RolldownPluginTest plan
bun test test/bun/BunPlugin.test.ts test/esbuild/EsbuildPlugin.test.ts test/rolldown/RolldownPlugin.test.ts test/bundler/DeferredLoad.test.ts