Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7b88eda
loose start for bun plugin
alii Aug 22, 2025
a4cc8f9
implement bun
alii Aug 22, 2025
1c39a86
support emitFile()
alii Aug 22, 2025
e53c582
fix Bun cases in integration test
alii Aug 22, 2025
0753e51
add bun to other test files
alii Aug 22, 2025
8e8455d
remove bun-types-no-globals from github
alii Aug 22, 2025
45c4b29
restore bun-types-no-globals from npm @^1.2
alii Aug 22, 2025
2f09a5c
bun does not yet support .onEnd, so for now we shouldn't fake it with…
alii Aug 22, 2025
da117f7
add Bun in the documentation
alii Aug 22, 2025
dfee0a2
some missing bun references in docs
alii Aug 22, 2025
9f6691c
support multiple plugins
alii Aug 22, 2025
8292e9d
use Bun namespace instead of importing module that won't necessarily …
alii Aug 22, 2025
c92f4a5
Bun is a cute pink color!
alii Aug 22, 2025
ef85cce
fix the transform hook
alii Aug 23, 2025
3a23dc1
fix for virtual modules
alii Aug 23, 2025
db4ab11
tidy up
alii Aug 23, 2025
ce130da
setup bun in ci
alii Aug 23, 2025
e8e5972
revert unplugin require path
alii Aug 23, 2025
eefe4b3
ignore bun in test-out folders
alii Aug 23, 2025
f7f89ed
update tests
alii Aug 23, 2025
01c0006
support onEnd
alii Aug 23, 2025
e13e5bd
remove
alii Aug 24, 2025
5afbdfa
implement guessLoader(), bun also now supports onEnd()
alii Aug 27, 2025
bf0ed7a
don't eat errors/warnings
alii Aug 27, 2025
cb5c8b0
we dont need to outdir for bun in this test
alii Aug 27, 2025
275c743
bun writebundle test
alii Aug 27, 2025
fd48b6e
Update to bun@1.2.22 (supports onEnd and onResolve)
alii Sep 23, 2025
82dff88
use onStart()
alii Sep 23, 2025
3806bff
define onStart() in mocks
alii Sep 23, 2025
69ad3a8
onStart
alii Sep 23, 2025
4ba86ee
ci: run vitest in Bun so we can run bun's tests
alii Sep 23, 2025
15b7195
Bun error message if building outside of Bun
alii Sep 23, 2025
78b5569
skip bun specific tests when not running in bun
alii Sep 23, 2025
38e501d
refactor
sxzz Nov 3, 2025
7724fc8
allow only
sxzz Nov 3, 2025
ae2fad1
ci: fix typecheck
sxzz Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,36 @@ permissions: {}
jobs:
unit-test:
uses: sxzz/workflows/.github/workflows/unit-test.yml@v1
with:
typecheck: pnpm run build && pnpm run typecheck

unit-test-bun:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

- name: Setup node
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: lts/*
cache: pnpm

- name: Setup Bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
with:
bun-version: latest

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm run build

- name: Test with bun
run: bun run scripts/buildFixtures.ts && bun -b vitest --allowOnly
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Currently supports:
- [Rspack](https://www.rspack.dev/)
- [Rolldown](https://rolldown.rs/)
- [Farm](https://www.farmfe.org/)
- [Bun](https://bun.com/)
- And every framework built on top of them.

## Documentations
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const title = 'Unplugin'
export const description = 'Unified plugin system. Support Vite, Rollup, webpack, esbuild, and every frameworks on top of them.'
export const description = 'Unified plugin system. Support Vite, Rollup, webpack, esbuild, Bun, and every frameworks on top of them.'
export const url = 'https://unplugin.unjs.io/'
export const ogImage = `${url}/og.png`
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Unplugin
</h1>
<p align="center">
Unified plugin system, Support Vite, Rollup, webpack, esbuild, and more
Unified plugin system, Support Vite, Rollup, webpack, esbuild, Bun, and more
</p>

<p align="center">
Expand Down
69 changes: 46 additions & 23 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ lastUpdated: false
- [Rspack](https://www.rspack.dev/)
- [Rolldown](https://rolldown.rs/)
- [Farm](https://www.farmfe.org/)
- [Bun](https://bun.com/)

## Trying It Online

Expand Down Expand Up @@ -153,6 +154,21 @@ export default defineConfig({
})
```

```ts [Bun]
// bun.config.ts
import Starter from 'unplugin-starter/bun'

await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
plugins: [
Starter({
/* options */
}),
],
})
```

```js [Vue-CLI]
// vue.config.js
module.exports = {
Expand Down Expand Up @@ -193,18 +209,18 @@ export default defineConfig({

## Supported Hooks

| Hook | Rollup | Vite | webpack | esbuild | Rspack | Farm | Rolldown |
| --------------------------------------------------------------------------------- | :-------------: | :--: | :-----: | :-------------: | :-------------: | :--: | :------: |
| [`enforce`](https://vite.dev/guide/api-plugin.html#plugin-ordering) | ❌ <sup>1</sup> | βœ… | βœ… | ❌ <sup>1</sup> | βœ… | βœ… | βœ… |
| [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) | βœ… | βœ… | βœ… | βœ… | βœ… <sup>5</sup> | βœ… | βœ… |
| ~~`loadInclude`~~<sup>2</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`load`](https://rollupjs.org/plugin-development/#load) | βœ… | βœ… | βœ… | βœ… <sup>3</sup> | βœ… | βœ… | βœ… |
| ~~`transformInclude`~~<sup>2</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`transform`](https://rollupjs.org/plugin-development/#transform) | βœ… | βœ… | βœ… | βœ… <sup>3</sup> | βœ… | βœ… | βœ… |
| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… |
| [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`writeBundle`](https://rollupjs.org/plugin-development/#writebundle)<sup>4</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| Hook | Rollup | Vite | webpack | esbuild | Rspack | Farm | Rolldown | Bun |
| --------------------------------------------------------------------------------- | :-------------: | :--: | :-----: | :-------------: | :-------------: | :--: | :------: | :-------------: |
| [`enforce`](https://vite.dev/guide/api-plugin.html#plugin-ordering) | ❌ <sup>1</sup> | βœ… | βœ… | ❌ <sup>1</sup> | βœ… | βœ… | βœ… | ❌ |
| [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) | βœ… | βœ… | βœ… | βœ… | βœ… <sup>5</sup> | βœ… | βœ… | βœ… |
| ~~`loadInclude`~~<sup>2</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`load`](https://rollupjs.org/plugin-development/#load) | βœ… | βœ… | βœ… | βœ… <sup>3</sup> | βœ… | βœ… | βœ… | βœ… |
| ~~`transformInclude`~~<sup>2</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`transform`](https://rollupjs.org/plugin-development/#transform) | βœ… | βœ… | βœ… | βœ… <sup>3</sup> | βœ… | βœ… | βœ… | βœ… |
| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… | ❌ |
| [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ <sup>6</sup> |
| [`writeBundle`](https://rollupjs.org/plugin-development/#writebundle)<sup>4</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ <sup>6</sup> |

::: details Notice

Expand All @@ -215,6 +231,7 @@ export default defineConfig({
3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results.
4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments.
5. Rspack supports `resolveId` with a minimum required version of v1.0.0-alpha.1.
6. Bun's plugin API doesn't have an `onEnd` hook yet, so `buildEnd` and `writeBundle` are not supported.

:::

Expand Down Expand Up @@ -253,6 +270,7 @@ export const webpackPlugin = unplugin.webpack
export const rspackPlugin = unplugin.rspack
export const esbuildPlugin = unplugin.esbuild
export const farmPlugin = unplugin.farm
export const bunPlugin = unplugin.bun
```

### Filters
Expand Down Expand Up @@ -289,14 +307,14 @@ More details can be found in the [Rolldown's documentation](https://rolldown.rs/

## Supported Context

| Context | Rollup | Vite | webpack | esbuild | Rspack | Farm | Rolldown |
| ------------------------------------------------------------------------------------- | :----: | :--: | :-----: | :-----: | :----: | :--: | :------: |
| [`this.parse`](https://rollupjs.org/plugin-development/#this-parse) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… |
| [`this.emitFile`](https://rollupjs.org/plugin-development/#this-emitfile)<sup>1</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… |
| [`this.warn`](https://rollupjs.org/plugin-development/#this-warn) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.error`](https://rollupjs.org/plugin-development/#this-error) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| Context | Rollup | Vite | webpack | esbuild | Rspack | Farm | Rolldown | Bun |
| ------------------------------------------------------------------------------------- | :----: | :--: | :-----: | :-----: | :----: | :--: | :------: | :-: |
| [`this.parse`](https://rollupjs.org/plugin-development/#this-parse) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… | βœ… |
| [`this.emitFile`](https://rollupjs.org/plugin-development/#this-emitfile)<sup>1</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) | βœ… | βœ… | βœ… | ❌ | βœ… | βœ… | βœ… | βœ… |
| [`this.warn`](https://rollupjs.org/plugin-development/#this-warn) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`this.error`](https://rollupjs.org/plugin-development/#this-error) | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |

::: info Notice

Expand All @@ -309,9 +327,9 @@ More details can be found in the [Rolldown's documentation](https://rolldown.rs/

### Bundler Supported

| Rollup | Vite | webpack | Rspack | esbuild | Farm | Rolldown |
| :--------------------: | :--: | :-----: | :----: | :-----: | :--: | :------: |
| βœ… `>=3.1`<sup>1</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| Rollup | Vite | webpack | Rspack | esbuild | Farm | Rolldown | Bun |
| :--------------------: | :--: | :-----: | :----: | :-----: | :--: | :------: | :-: |
| βœ… `>=3.1`<sup>1</sup> | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |

::: details Notice

Expand Down Expand Up @@ -409,6 +427,9 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (
farm: {
// Farm plugin
},
bun: {
// Bun plugin
},
}
}

Expand All @@ -424,6 +445,7 @@ Each of the function takes the same generic factory argument as `createUnplugin`

```ts
import {
createBunPlugin,
createEsbuildPlugin,
createFarmPlugin,
createRolldownPlugin,
Expand All @@ -440,4 +462,5 @@ const esbuildPlugin = createEsbuildPlugin(/* factory */)
const webpackPlugin = createWebpackPlugin(/* factory */)
const rspackPlugin = createRspackPlugin(/* factory */)
const farmPlugin = createFarmPlugin(/* factory */)
const bunPlugin = createBunPlugin(/* factory */)
```
8 changes: 7 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar: false
hero:
name: Unplugin
text: The Unified<br>Plugin System
tagline: Supports Vite, Rollup, webpack, esbuild, and every framework built on top of them.
tagline: Supports Vite, Rollup, webpack, esbuild, Bun, and every framework built on top of them.
image:
light: /logo_light.svg
dark: /logo_dark.svg
Expand Down Expand Up @@ -64,6 +64,12 @@ features:
icon:
src: /features/rolldown.svg

- title: Bun
details: All-in-one JavaScript runtime & toolkit
link: https://bun.com/
icon:
src: /features/bun.svg

- title: More
details: More supported bundlers...
link: /guide/#supported-hooks
Expand Down
1 change: 1 addition & 0 deletions docs/public/features/bun.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@types/picomatch": "catalog:",
"ansis": "catalog:",
"bumpp": "catalog:",
"bun-types-no-globals": "catalog:",
"esbuild": "catalog:",
"eslint": "catalog:",
"eslint-plugin-format": "catalog:",
Expand Down
15 changes: 13 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ catalog:
'@types/picomatch': ^4.0.2
ansis: ^4.2.0
bumpp: ^10.3.1
bun-types-no-globals: ^1.2.22
esbuild: ^0.25.12
eslint: ^9.39.0
eslint-plugin-format: ^1.0.2
Expand Down
9 changes: 9 additions & 0 deletions scripts/buildFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { join, resolve } from 'node:path'
import process from 'node:process'
import c from 'ansis'

const isBun = !!process.versions.bun

const dir = resolve(import.meta.dirname, '../test/fixtures')
let fixtures = await readdir(dir)

Expand All @@ -16,6 +18,13 @@ for (const name of fixtures) {
if (existsSync(join(path, 'dist')))
await rm(join(path, 'dist')).catch(() => {})

if (isBun) {
console.log(c.magentaBright.inverse.bold`\n Bun `, name, '\n')
execSync('bun --version', { cwd: path, stdio: 'inherit' })
execSync('bun bun.config.js', { cwd: path, stdio: 'inherit' })
continue // skip other builders in bun environment
}

console.log(c.yellow.inverse.bold`\n Vite `, name, '\n')
execSync('npx vite --version', { cwd: path, stdio: 'inherit' })
execSync('npx vite build', { cwd: path, stdio: 'inherit' })
Expand Down
Loading
Loading