Back

/ 1 min read

Esbuild - An extremely fast bundler for Typescript

Typescript project build time performance comparison (tsc vs esbuild)

Lets have a simple Typescript Express base API to test the build time differences:

import express, { Request, Response } from 'express'
const app = express()
const port = 3000
app.get('/ping', (request: Request, response: Response) => {
response.status(200).json({ status: 'pong' })
})
app.listen(port, () => {
console.log(`Application is running on port ${port}.`)
})
  • Install typescript, esbuild dependencies and add build config files.
  • Setup package.json build, start commands.

Now let’s check the build time for: tsc

Build

time npm run ts:build

Output:

Terminal window
> typescript-esbuild@1.0.0 ts:build
> tsc
real 0m3.291s
user 0m0.030s
sys 0m0.166s

Now let’s check the build time for: esbuild

Build

time npm run es:build

Output:

Terminal window
> typescript-esbuild@1.0.0 es:build
> node ./esbuild.js
real 0m1.413s
user 0m0.030s
sys 0m0.230s

Run

npm start

Output:

Terminal window
> typescript-esbuild@1.0.0 start
> node build/index.js
Application is running on port 3000.

Performance comparison

As per the build time result it’s clear that esbuild perform much better than default Typescript built in tsc in terms of build timing.

For more Benchmark details,fallow the Link