{"id":19061,"library":"babel-plugin-feature-flags","title":"babel-plugin-feature-flags","description":"A Babel 6 plugin that replaces feature flag call expressions (e.g., `isEnabled('feature')`) with boolean literals based on a static configuration map. Current stable version is 0.3.1, with low release cadence. It targets Babel 6 only; Babel 5 users must use 0.2.x. Key differentiator: it works with any import name and supports 'dynamic' flags that are left untouched. Typically paired with a dead code elimination step (Uglify, etc.). No TypeScript support; no security incidents reported.","status":"maintenance","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/ember-cli/babel-plugin-feature-flags","tags":["javascript","babel","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-feature-flags","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-feature-flags","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-feature-flags","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a Babel plugin, used in .babelrc or babel.config.js — not imported directly in source code.","wrong":"import babelPluginFeatureFlags from 'babel-plugin-feature-flags';","symbol":"babel-plugin-feature-flags","correct":"module.exports = {\n  plugins: [\n    ['feature-flags', { import: { module: 'my-features' }, features: { 'new-feature': 'disabled' } }]\n  ]\n};"},{"note":"The default import name is configurable via options.import.name (default is 'default'). If using a named import, set options.import.name to the export name.","wrong":"import { isEnabled } from 'my-features';","symbol":"default import of feature function","correct":"import isEnabled from 'my-features';"},{"note":"Values must be exactly the strings 'enabled', 'disabled', or 'dynamic'. Booleans or other strings will not work.","wrong":"{\n  'my-feature': 'true',\n  'beta-feature': false\n}","symbol":"feature flags configuration","correct":"{\n  'my-feature': 'enabled',\n  'beta-feature': 'disabled',\n  'experimental': 'dynamic'\n}"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [[\"feature-flags\", {\n    \"import\": {\n      \"module\": \"@app/features\"\n    },\n    \"features\": {\n      \"new-checkout\": \"enabled\",\n      \"dark-mode\": \"disabled\",\n      \"payment-v2\": \"dynamic\"\n    }\n  }]]\n}\n\n// source.js\nimport feature from '@app/features';\n\nif (feature('new-checkout')) {\n  console.log('New checkout flow');\n}\n\nif (feature('dark-mode')) {\n  document.body.classList.add('dark');\n}\n\nif (feature('payment-v2')) {\n  // runtime check left intact\n}\n\n// after babel transform:\nif (true) {\n  console.log('New checkout flow');\n}\n// if (false) block removed by dead code elimination\nif (feature('payment-v2')) {}","lang":"javascript","description":"Configures feature flags via .babelrc with enabled/disabled/dynamic values and shows transformation of flag calls."},"warnings":[{"fix":"If using Babel 5, pin to 0.2.x or upgrade to Babel 6.","message":"Babel 5 support dropped in 0.3.0. Use 0.2.x for Babel 5.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Migrate to Babel 7 and use equivalent plugin or inline replacement.","message":"Babel 6 is itself deprecated. Consider upgrading to Babel 7+ with @babel/plugin-feature-flags (if available) or custom plugin.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure feature values are one of the three strings.","message":"Feature flag values must be the exact strings 'enabled', 'disabled', or 'dynamic'. Other values (e.g., booleans) are silently ignored, leaving call expressions untransformed.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install babel-plugin-feature-flags@0.3.1 --save-dev and ensure babel-core version 6.x.","cause":"Plugin not installed or babel version mismatch (Babel 7 vs Babel 6).","error":"Error: Cannot find module 'babel-plugin-feature-flags'"},{"fix":"Add the correct import (e.g., import isEnabled from 'my-features';) matching the options.import.module.","cause":"The import of the feature function is not present in the source file, but the call expression is still there after transform.","error":"ReferenceError: isEnabled is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}