Skip to content

Unify bundler plugins to esbuild-shaped Plugin API (#49) - #110

Draft
nounder wants to merge 1 commit into
mainfrom
cursor/fix-49-esbuild-plugin-c215
Draft

Unify bundler plugins to esbuild-shaped Plugin API (#49)#110
nounder wants to merge 1 commit into
mainfrom
cursor/fix-49-esbuild-plugin-c215

Conversation

@nounder

@nounder nounder commented Aug 12, 2026

Copy link
Copy Markdown
Owner

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 unplugin dependency.

Changes

  • bundler/Plugin with onResolve / onLoad (+ Bun-style defer)
  • Adapters: BunPlugin, EsbuildPlugin, RolldownPlugin
  • Refactor Tailwind to return the generic Plugin

Test plan

  • bun test test/bun/BunPlugin.test.ts test/esbuild/EsbuildPlugin.test.ts test/rolldown/RolldownPlugin.test.ts test/bundler/DeferredLoad.test.ts
Open in Web Open in Cursor 

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify bundler-specific plugin to esbuild plugin

2 participants