Registry /
serialization / babel-plugin-transform-flow-enums
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default export (plugin function)
✓ module.exports = require('babel-plugin-transform-flow-enums');
✗ import plugin from 'babel-plugin-transform-flow-enums'; // Wrong: plugin is CommonJS, not ESM
This package is CommonJS-only without ESM support.
babel.config.js usage
✓ plugins: ['babel-plugin-transform-flow-enums']
✗ plugins: [['babel-plugin-transform-flow-enums', { getRuntime: ... }]] // Wrong: passing options as array is correct only when options are provided; the string form without options is also valid
Options can be provided as the second element of an array in the plugin list.
getRuntime option
✓ plugins: [['babel-plugin-transform-flow-enums', { getRuntime: (t) => t.memberExpression(t.identifier('require'), t.stringLiteral('flow-enums-runtime')) }]]
✗ plugins: [['babel-plugin-transform-flow-enums', { getRuntime: 'flow-enums-runtime' }]] // Wrong: getRuntime must be a function, not a string
The getRuntime option receives Babel types (t) and must return a Babel AST node that references the runtime.
Set up Babel to transform Flow Enums using the required syntax plugin and runtime.
// Install dependencies:
// npm install --save-dev babel-plugin-transform-flow-enums @babel/plugin-syntax-flow flow-enums-runtime
// babel.config.js file:
module.exports = {
plugins: [
['@babel/plugin-syntax-flow', { enums: true }],
'babel-plugin-transform-flow-enums'
]
};
// Input file (test.js):
// @flow
enum Status { Active, Inactive }
// After transform:
// const Status = require('flow-enums-runtime').create(['Active', 'Inactive']);
Errors
Common errors & fixes
SyntaxError: Support for the experimental syntax 'Flow' isn't currently enabled
Missing @babel/plugin-syntax-flow plugin.
fixAdd '@babel/plugin-syntax-flow' (with { enums: true } if using enums) to your Babel plugins. Cannot find module 'flow-enums-runtime'
Missing runtime dependency in transformed code.
fixRun 'npm install flow-enums-runtime' and ensure it's in your dependencies.
Error: [BABEL] unknown: .plugins[1][1] must be an object, false, or undefined (BCP 6)
Passing options as a string instead of an array or object.
fixUse array form for plugin options: ['babel-plugin-transform-flow-enums', { getRuntime: ... }] Audit
Dependencies
@babel/plugin-syntax-flowrequiredRequired for parsing Flow syntax including enums; must be enabled with {enums: true} configuration.
flow-enums-runtimerequiredRuntime dependency that this plugin generates calls to.