Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Floffah/esbuild-plugin-d.ts
🔌 Convenience plugin for compiling typescript definitions with ESBuild
https://github.com/Floffah/esbuild-plugin-d.ts
declarations dts esbuild esbuild-plugin plugin typescript
Last synced: 3 months ago
JSON representation
🔌 Convenience plugin for compiling typescript definitions with ESBuild
- Host: GitHub
- URL: https://github.com/Floffah/esbuild-plugin-d.ts
- Owner: Floffah
- License: mit
- Created: 2021-05-08T09:23:45.000Z (over 3 years ago)
- Default Branch: canary
- Last Pushed: 2024-01-19T11:46:38.000Z (10 months ago)
- Last Synced: 2024-04-26T19:22:34.199Z (7 months ago)
- Topics: declarations, dts, esbuild, esbuild-plugin, plugin, typescript
- Language: TypeScript
- Homepage: http://npm.im/esbuild-plugin-d.ts
- Size: 3.43 MB
- Stars: 51
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# `esbuild-plugin-d.ts`
ESBuild plugin for compiling typescript declarations
## WARNING
This plugin was made to make it easier to build declarations without running two commands simultaneously. It will add a lot of overhead to your build time and should only really be used as a last resort.
### Alternatives
- [TSUP](https://npm.im/tsup) - Similar usage to this plugin, but more stable and configurable. A CLI tool wrapped around ESBuild rather than a plugin
- [Estrella](https://npm.im/estrella)## Usage
```js
const { dtsPlugin } = require("esbuild-plugin-d.ts");
const { build } = require("esbuild");
// OR
import { dtsPlugin } from "esbuild-plugin-d.ts";
import { build } from "esbuild";build({
entryPoints: ["./test/index.ts"],
outdir: "./dist",
plugins: [dtsPlugin({
// Optional options here
})]
})```
The plugin uses the typescript compiler api. You don't need to enable declarations in your tsconfig.
The plugin does not enable incremental mode unless `incremental` is set to true in your tsconfig. When this is enabled, the plugin will automatically assume a tsbuildinfo file but will respect your config if set there.
Be aware that if you delete your dist folder and have incremental mode enabled, your declarations may not be built.
### Bundling
This plugin has experimental declaration bundling support, to enable it, set `experimentalBundling` to true in the plugin's options as follows:
Note that this also requires you to set your entry points in ESBuild.
```js
build({
entryPoints: ["./test/index.ts"],
outdir: "./dist",
plugins: [dtsPlugin({
experimentalBundling: true
})]
})
```Once proven to be stable, this will be enabled when `bundle` is set to true in ESBuild and will be documented properly.
### Options
- `outDir: string` (DEPRECATED) - override the output directory - you should define declarationDir in your tsconfig instead. The plugin will also fall back to your tsconfig outDir or esbuild outdir
- `tsconfig: string | object` - A path to your tsconfig or a tsconfig object. The plugin will automatically find your tsconfig if you don't specify one.All other functionality is derived from your tsconfig
See tests here [here](./tests)