Babel preset for transforming TypeScript const enums. Version 1.0.0. It runs babel-plugin-const-enum only on .ts/.tsx files to prevent syntax errors on non-TypeScript files. Provides two transform options: removeConst (default) reverts const enum to regular enum, while constObject inlines values into a const object literal for minification. Must be placed after @babel/preset-typescript in the preset order to work correctly. Lightweight, focused solution for using const enums with Babel.
npm install babel-preset-const-enumVerified import paths — ran on the pinned version, not inferred.
Shows how to configure babel-preset-const-enum with @babel/preset-typescript and constObject transform, then run Babel on a .ts file.
Put 'const-enum' after '@babel/preset-typescript' in the preset order.
Use transform: 'constObject' if you want inlined values for minification.
Set transform: 'constObject' explicitly for production builds.
Reorder presets: put '@babel/preset-typescript' first, then 'const-enum'.
Install: npm install --save-dev babel-preset-const-enum
Use transform: 'constObject' to create a const object that avoids hoisting issues.