{"id":19096,"library":"babel-plugin-kea","title":"babel-plugin-kea","description":"A Babel plugin that automatically generates path strings for Kea logic stores based on the file path. Version 3.0.0 is the latest stable release. It eliminates the need to manually specify a `path` property in every `kea()` call, with support for dynamic keys and custom path prefix configuration. Unlike manual path management, this plugin ensures consistency and reduces boilerplate in Kea-based projects. It requires Kea 3.x and is intended for build-time usage with Babel.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/keajs/babel-plugin-kea.gi","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-kea","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-kea","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-kea","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: plugin runs as a Babel transform","package":"@babel/core","optional":false}],"imports":[{"note":"Add to .babelrc plugins array. With options: ['babel-plugin-kea', { path: './src' }]","wrong":"plugins: ['babel-plugin-kea', { path: './src' }]  (wrong syntax, must be nested array)","symbol":"plugin (default)","correct":"plugins: ['babel-plugin-kea']"},{"note":"Options object must be second element in a tuple.","wrong":"plugins: ['babel-plugin-kea', { path: './src' }]  (options must be inside nested array)","symbol":"Plugin with options","correct":"plugins: [['babel-plugin-kea', { path: './src' }]]"},{"note":"Plugin is a function, not an object with default property.","wrong":"const plugin = require('babel-plugin-kea').default  (default export is the plugin function)","symbol":"Programmatic usage","correct":"const plugin = require('babel-plugin-kea'); require('@babel/core').transform(code, { plugins: [plugin] })"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    \"babel-plugin-kea\"\n  ]\n}\n\n// With path prefix to skip 'frontend/src':\n// {\n//   \"plugins\": [\n//     [\"babel-plugin-kea\", { \"path\": \"./frontend/src\" }]\n//   ]\n// }","lang":"javascript","description":"Basic Babel configuration enabling the plugin and an example with custom path prefix to trim root directory."},"warnings":[{"fix":"Upgrade Kea to 3.x or use babel-plugin-kea@2.x for Kea 2.x.","message":"Plugin v3.x only works with Kea 3.x. Using with Kea 2.x will break.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Remove explicit path from kea() calls to let plugin generate them automatically.","message":"If a kea({ path: ... }) already has a path string, the plugin will NOT override it. It only adds path when missing.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the 'path' option to trim a prefix (e.g., './src') to keep paths stable if files move under src.","message":"The generated path uses the file path relative to the project, not the module name. Moving files changes the path.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use path: () => [...] for dynamic paths; static paths as arrays are not modified.","message":"Plugin auto-generates path based on file path. To override path for a specific logic, you must still provide a custom path function; an array or string will be treated as custom path and not overwritten.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install babel-plugin-kea --save-dev' or 'yarn add babel-plugin-kea --dev'.","cause":"Plugin not installed or not in node_modules.","error":"Error: Could not find plugin \"babel-plugin-kea\""},{"fix":"Use 'const plugin = require('babel-plugin-kea')' (no .default).","cause":"Incorrect import/require when using programmatic API (e.g., require('babel-plugin-kea').default).","error":"TypeError: babelPluginKea is not a function"},{"fix":"Use [['babel-plugin-kea', { path: './src' }]] not ['babel-plugin-kea', { path: './src' }].","cause":"Misconfigured .babelrc plugins array (e.g., missing nested array).","error":"Error: Plugin options must be an array when using two-element tuple"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}