Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript ES5 helper methods duplicated

I'm using typescript and webpack to compile my ES+ code down to ES5, with each module contained in its own output bundle.

For example:

class User {} = 1.js
class Table {} = 2.js

When looking at the output I'm noticing duplicate functions across the bundles, e.g:

__decorate
__awaiter
__generator

These are obviously helpers from the transpile down to ES5, is there any way to move these into a shared bundle to reduce duplication?

like image 771
jahilldev Avatar asked Sep 10 '25 19:09

jahilldev


1 Answers

This is achieved with importHelpers compiler option. It imports all helper functions in every place they are needed.

It requires to install tslib package.

like image 186
Estus Flask Avatar answered Sep 13 '25 12:09

Estus Flask