tslite
is a redistribution of typescript
package with same public API but much smaller install size!
The 'typescript' package's installation size has significantly increased over time and is now unreasonably large for use as a project dependency.
However, this issue has been on the TypeScript team's radar (microsoft/TypeScript#27891), and with the continuous efforts of @jakebailey and the rest of the TypeScript team to reduce the installation size, there are certain limitations preventing further size reduction.
Nevertheless, we can make further optimizations for end-users. The aim of this package is not to impede TypeScript's core improvements but to offer an alternative distribution tailored for end-users who require TypeScript as a peer dependency in their projects.
Check build.ts
for build steps.
Typescript cannot be officially distributed minified because of preserving stack traces and allowing the package to be patched. However, for normal daily use of typescript, it does not matter unless there is a bug with typescript itself which in this case, we can temporarily switch off tslite. Minifying big JS files has a huge impact on the install size. tslite only minifies non lib.
files over 250KB using UglifyJS.
Typescript package ships with ~3.8M
of localized translation files for error messages which are usually not used. TSLite removed them.
I am thinking about more possible ideas to make typescript lib even smaller. For instance, we can lazily import compiler bits from the network on demand and cache them in a global user file being shared across projects. Ideas and PRs are more than welcome!!
Keep typescript
as a devDependency
and use resolutions to alias tslite
:
Using npm overrides:
// package.json
{
"overrides": {
"typescript": "npm:tslite@latest",
},
}
Using yarn selective dependency resolutions or pnpm overrides:
// package.json
{
"resolutions": {
"typescript": "npm:tslite@latest",
},
}