Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stuyk/bun-plugin-type-declarations
Generate TypeScript declarations with TSC as a bun bundler plugin
https://github.com/stuyk/bun-plugin-type-declarations
Last synced: about 22 hours ago
JSON representation
Generate TypeScript declarations with TSC as a bun bundler plugin
- Host: GitHub
- URL: https://github.com/stuyk/bun-plugin-type-declarations
- Owner: Stuyk
- Created: 2023-09-14T03:23:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-14T03:27:27.000Z (over 1 year ago)
- Last Synced: 2024-12-07T20:08:28.566Z (15 days ago)
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bun-plugin-type-declarations
Automatically build typings for your source code while bundling with Bun.
**Note: Currently Bun related API functionality cannot generate Typings with TSC**
## TSConfig Setup
If your source files are located in `src/index.ts` your `tsconfig.json` should reflect the following:
```json
"outDir": "build",
"composite": false,
"rootDir": "./src",
```**At the minimum `composite` must be set to false.**
## Bundling
Install this package with `bun`.
```bash
bun install -d bun-plugin-type-declarations
```Create a `build.ts` file that bundles your source code.
`BunTypeDeclarations` takes a `tsconfig.json` absolute path to generate your typings.
```ts
import BunTypeDeclarations from 'bun-plugin-type-declarations';await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './build',
plugins: [BunTypeDeclarations('tsconfig.json')],
target: 'node',
minify: true,
}).catch((err) => {
console.log(err);
});
```## Bundling Issues
If you run into the following error:
```
src/index.ts(10,60): error TS4060: Return type of exported function has or is using private name 'BunPlugin'.
```There is currently nothing that can be done about this other than not using `Bun` related functionality directly. This means we can't really have Typings exported for Bun related functionality.
This message will be removed if it ever gets fixed.