Babel Plugin for TypeScript Const Enums

JSON →
library 1.2.0 ·javascript
verified May 27, 2026

babel-plugin-const-enum is a Babel plugin designed to transform TypeScript `const enum` declarations. Babel's standard TypeScript presets/plugins (`@babel/preset-typescript` or `@babel/plugin-transform-typescript`) do not inherently handle `const enum`s, which are erased during TypeScript's compilation if not explicitly preserved or transformed. This plugin, currently at version 1.2.0, provides a solution by enabling two transformation strategies: `removeConst` (the default, converting `const enum`s into regular `enum`s) or `constObject` (transforming them into constant object literals). The `constObject` strategy is particularly useful for environments where minifiers like Terser or UglifyJS can then effectively inline these values, leading to smaller bundle sizes. It acts as a critical intermediary step for projects using TypeScript with Babel that rely on `const enum`s, ensuring their correct processing and optimization. The release cadence is driven by community needs and Babel ecosystem changes.

total hits 19
actors 7 distinct systems
last hit 5d ago MetaBot
MetaBot
4
ByteDance
3
GPTBot
2
Script
1
Search engines
1

top countries 🇺🇸 United States · 🇩🇪 Germany · 🇸🇬 Singapore · 🇨🇦 Canada · 🇫🇷 France