-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Typescript emits helper functions into produced js modules depending on features used.
It also has a compiler option "importHelpers": true
Which emits something like import {decorate} from "tslib"
or require equivalent depending on module format.
Size of tslib module is ~16kb
On large codebases source code of emitted helpers per module tends to grow large and it is duplicated code all over the transpiled codebase.
For example: __decorate helper
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
is 563 bytes.
In Theia packages we use to build our IDE it is encountered 952 times which gives us roughly 500kb of minified bundle size for only the decorate helper copy-pasted
all over.
@theia
scoped packages contribute 872 of those copies.
Feature Description:
Please consider taking a dependency on tslib for theia packages and changing importHelpers
compiler option to true
One decorate function is plenty enough for the whole bundle.