Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 1.48 KB

README.md

File metadata and controls

57 lines (45 loc) · 1.48 KB

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 feature, which is not supported by esbuild. 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:

    npm install --save-dev esbuild-plugin-tsc typescript
  2. Add this plugin to your esbuild build script:

    Javascript:

    +const esbuildPluginTsc = require('esbuild-plugin-tsc');
     ...
     esbuild.build({
       ...
       plugins: [
    +    esbuildPluginTsc(),
       ],
     })

    Typescript:

    +import esbuildPluginTsc from 'esbuild-plugin-tsc';
     ...
     esbuild.build({
       ...
       plugins: [
    +    esbuildPluginTsc(),
       ],
     })

Config

esbuildPluginTsc({
    // If empty, uses tsconfig.json
    tsconfigPath?: string,
    // If true, force compilation with tsc
    force?: boolean,
    // If true, enables tsx file support
    tsx?: boolean
})