• Stars
    star
    110
  • Rank 315,808 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An esbuild plugin which uses tsc to compile typescript files.

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
})