Repository navigation
Description
Describe the feature
[email protected] provides first-class adapters for Vite, Webpack, Rollup, esbuild, and Rspack, but it does not currently expose a first-class Rsbuild adapter.
Specifically, there is no:
createRsbuildPlugin(factory)createUnplugin(factory).rsbuild
Rsbuild is built on top of Rspack, so many unplugin-based transforms can work in an Rsbuild project through a manual Rspack configuration workaround. However, package authors cannot expose a clean my-plugin/rsbuild entrypoint with the same ergonomics as existing adapters.
Motivation
Rsbuild users currently need to wire unplugin-based Rspack plugins through tools.rspack, which is less discoverable and less consistent than the existing adapter model.
For plugin authors, this also means packages can expose:
my-plugin/vitemy-plugin/webpackmy-plugin/rollupmy-plugin/esbuildmy-plugin/rspack
but not a native:
my-plugin/rsbuild
A first-class Rsbuild adapter would make Rsbuild support consistent with the rest of the supported build tools.
Proposed API
import {createRsbuildPlugin} from 'unplugin'
import {unpluginFactory} from './index.js'
export default createRsbuildPlugin(unpluginFactory)And through createUnplugin:
import {createUnplugin} from 'unplugin'
const plugin = createUnplugin(factory)
export default plugin.rsbuildExpected Usage
// rsbuild.config.ts
import {defineConfig} from '@rsbuild/core'
import myPlugin from 'my-plugin/rsbuild'
export default defineConfig({
plugins: [
myPlugin({
/* plugin options */
}),
],
})Current Workaround
Today, Rsbuild users can often route the Rspack adapter manually through tools.rspack:
// rsbuild.config.ts
import {defineConfig} from '@rsbuild/core'
import myPlugin from 'my-plugin/rspack'
export default defineConfig({
tools: {
rspack(config) {
config.plugins ??= []
config.plugins.push(myPlugin())
},
},
})This works for some plugins, but it is not as ergonomic or discoverable as a native Rsbuild plugin. It also requires users to know that Rsbuild is Rspack-based and that the Rspack adapter can be manually inserted into the generated Rspack config.
Additional information
- Would you be willing to help implement this feature?
Activity