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:
> typescript-esbuild@1.0.0 ts:build> tsc
real 0m3.291suser 0m0.030ssys 0m0.166s
Now let’s check the build time for: esbuild
Build
time npm run es:build
Output:
> typescript-esbuild@1.0.0 es:build> node ./esbuild.js
real 0m1.413suser 0m0.030ssys 0m0.230s
Run
npm start
Output:
> 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