[Typescript] Performance Bundling and tslib

When we use class extend in typescript:

// app.ts
export default class App {}


// bar.ts
export defulat class Bar extends App {

}

 

After compiling, we will see an "__extends" file stays in many sub class:

 

Considering this "__extends" function will repeat many times in our compiled code, we wish it only appear once, not in each files.

 

To fix it we can do:

//tsconfig.json

"noEmitHelpers": true,
"importHelpers": true

And install:

npm i tslib --save

It contians all kind of helper functions. Which can reduces our bundle sizes a lot.

 

posted @ 2020-10-05 18:29  Zhentiw  阅读(76)  评论(0编辑  收藏  举报