Minifying Private Fields in TypeScript
summary
A short webpack loader runs a TypeScript custom transformer (using the TypeScript compiler API) to rename private class fields by prefixing them with underscores so Closure-style minification is safe. This approach preserves type-aware correctness (avoiding Babel-only misrenaming of cross-instance or dynamic accesses) and was toggled in production to save about 31 KB raw and ~2% gzipped in the player bundle.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 3:54Private fields in TypeScript
- 7:11Google Closure Compiler issues
- 10:50Alternative solutions
- 15:53Babel and plugins
- 19:16Minifying private fields attempts
- 25:10Custom loader creation
- 27:39Implementation and deployment
- 28:01Optimization results
- 32:40Q&A
related talks
22mA Trip into the Compiler
34mNot Your Uncle’s Clean Code (TypeScript Edition)
38mSafer TypeScript
57mTypeScript : More than just another JS transpiler
38mPorting 100K lines of code to TypeScript
24mThe Path to Native TypeScript
28mTypescript Performance: Going Beyond The Surface
36mNavigating TypeScript Performance for Better Dev Experience
