https://github.com/thomaschaaf/esbuild-plugin-tsc
An esbuild plugin which uses tsc to compile typescript files.
https://github.com/thomaschaaf/esbuild-plugin-tsc
Last synced: 9 months ago
JSON representation
An esbuild plugin which uses tsc to compile typescript files.
- Host: GitHub
- URL: https://github.com/thomaschaaf/esbuild-plugin-tsc
- Owner: thomaschaaf
- License: mit
- Created: 2021-03-06T20:29:00.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-24T19:14:06.000Z (over 1 year ago)
- Last Synced: 2025-09-05T17:41:50.047Z (10 months ago)
- Language: TypeScript
- Size: 227 KB
- Stars: 134
- Watchers: 1
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-tsc
An esbuild plugin which uses tsc to compile typescript files.
## Why?
Esbuild natively supports typescript files - so if you are not using exotic typescript features this plugin is not meant for you!
I wanted to use [`typescripts emitDecoratorMetadata`](https://www.typescriptlang.org/tsconfig#emitDecoratorMetadata) feature, which is [not supported by esbuild](https://github.com/evanw/esbuild/issues/257). If you are only using typescript decorators in some files, this plugin allows you to convert only the files containing decorators and lets esbuild handle all other files.
If for some reason you want to use typescripts compiler for all files you can simple set the `force` option.
## Basic Usage
1. Install this plugin in your project:
```sh
npm install --save-dev esbuild-plugin-tsc typescript
```
2. Add this plugin to your esbuild build script:
Javascript:
```diff
+const esbuildPluginTsc = require('esbuild-plugin-tsc');
...
esbuild.build({
...
plugins: [
+ esbuildPluginTsc(),
],
})
```
Typescript:
```diff
+import esbuildPluginTsc from 'esbuild-plugin-tsc';
...
esbuild.build({
...
plugins: [
+ esbuildPluginTsc(),
],
})
```
## Config
```typescript
esbuildPluginTsc({
// If empty, uses tsconfig.json
tsconfigPath?: string,
// If true, force compilation with tsc
force?: boolean,
// If true, force TypeScript to treat files without the `.mts` extension as ESM
forceEsm?: boolean,
// If true, enables tsx file support
tsx?: boolean
})
```