⚠️ This package is deprecated and no longer maintained, since Bun now supportsemitDecoratorMetadata
.
A Bun plugin for transpiling TypeScript with SWC (Speedy Web Compiler).
As of September 2023, Bun does not support emitDecoratorMetadata
, which limits its compatibility with popular libraries such as NestJS. To address this issue, this plugin transpiles TypeScript imports using SWC, then feeds the resulting JavaScript code back into Bun's default JavaScript loader.
bun add --dev bun-plugin-swc
First, create a preload script to load the plugin:
preload.ts
import { plugin } from 'bun';
import swcPlugin from 'bun-plugin-swc';
void plugin(swcPlugin());
Then, add the preload script to your bunfig.toml
:
bunfig.toml
preload = ["./preload.ts"]
[test]
preload = ["./preload.ts"]
For a real world example, see the example
project in this repository.