

This Bun plugin generates dts files for your TypeScript projects.
Features
- Auto-imports support for Bun
Usage
bun install -d bun-plugin-auto-imports
You may now use the plugin:
import type { AutoImportsOptions } from 'bun-plugin-auto-imports'
import { plugin } from 'bun'
import { autoImports } from 'bun-plugin-auto-imports'
const options: AutoImportsOptions = {
presets: ['solid-js'],
imports: [{ name: 'z', from: 'zod' }],
dts: `./src/auto-import.d.ts`,
}
plugin(autoImports(options))
Bun.serve({
fetch: handler,
port: 3000,
})
In your "server file," you may now use the auto-imported modules:
const Body = z.object({
msg: z.string(),
})
export async function handler(req: Request) {
try {
const body = await req.json()
const data = Body.parse(body)
return new Response(`Received: ${data.msg}`)
}
catch (e) {
return new Response('Invalid body', { status: 400 })
}
}
As a minor side note, if you are familiar with unimport, AutoImportsOptions proxies UnimportOptions.
Testing
bun test
Changelog
Please see our releases page for more information on what has changed recently.
Contributing
Please review the Contributing Guide for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
Discussions on GitHub
For casual chit-chat with others using this package:
Join the Stacks Discord Server
Postcardware
You will always be free to use any of the Stacks OSS software. We would also love to see which parts of the world Stacks ends up in. Receiving postcards makes us happy—and we will publish them on our website.
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
Credits
Many thanks to the following core technologies & people who have contributed to this package:
License
The MIT License (MIT). Please see LICENSE for more information.
Made with đź’™