Giter Club home page Giter Club logo

esbuild-node-tsc's Introduction

⚡️ esbuild-node-tsc

Build your Typescript Node.js projects using blazing fast esbuild.

Since esbuild can build large typescript node projects in subsecond speeds, this is quite useful for development builds too if you want to stick with tsc for production builds.

Please note this library doesnt do typechecking. For typechecking please continue to use tsc.

How does it work?

esbuild-node-tsc reads the tsconfig.json and builds the typescript project using esbuild. esbuild is the fastest typescript builder around. It also copies the non ts files such as json, graphql files, images,etc to the dist folder. If the assets are not copied correctly check the configuration guide below.

Installation

npm install --save-dev esbuild-node-tsc

Usage

npx esbuild-node-tsc

or use the short form.

npx etsc

Additionally, you can add it to your build scripts

{
  "name": "myproject",
  "version": "0.1.0",
  "scripts": {
    "dev": "etsc" 
  }
}

Then just run

npm run dev

Live reloading (nodemon ❤️ esbuild-node-tsc)

Since esbuild can build large typescript projects in subsecond speeds you can use this library instead of ts-node-dev or ts-node which usually slow down when project scales.

To achieve live reloading:

npm install --save-dev nodemon esbuild-node-tsc

Then add the following script to package.json

{
  "name": "myproject",
  "version": "0.1.0",
  "scripts": {
    "dev": "nodemon"
  }
}

And add a nodemon.json

{
  "watch": ["src"],
  "ignore": ["src/**/*.test.ts"],
  "ext": "ts,mjs,js,json,graphql",
  "exec": "etsc && node ./dist/index.js",
  "legacyWatch": true
}

Finally run

npm run dev

Comparison with tsc

Optional configuration

By default esbuild-node-tsc should work out of the box for your project since it reads the necessary configuration from your tsconfig.json

But if things are not working as expected you can configure esbuild-node-tsc by adding etsc.config.js along side tsconfig.json.

Example etsc.config.js

module.exports = {
  outDir: "./dist",
  esbuild: {
    minify: false,
    target: "es2015",
  },
  assets: {
    baseDir: "src",
    filePatterns: ["**/*.json"],
  },
};

All of the above fields are optional

License

MIT

esbuild-node-tsc's People

Contributors

a7ul avatar gromnan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.