{"id":19144,"library":"babel-plugin-recast","title":"babel-plugin-recast","description":"Babel plugin (v0.2.0, stable) that integrates recast's AST parsing and code generation to preserve original formatting during Babel transformations, ideal for codemods. Unlike standard Babel plugins that discard formatting, it uses undocumented parserOverride/generatorOverride hooks to maintain whitespace and style. Requires peer dependency recast 0.x. Light maintenance, release cadence is minimal.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/conartist6/babel-plugin-recast","tags":["javascript","babel","recast","codemod"],"install":[{"cmd":"npm install babel-plugin-recast","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-recast","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-recast","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for AST manipulation and formatting preservation","package":"recast","optional":false}],"imports":[{"note":"Used as a Babel plugin name string in config, not a direct import.","wrong":"import plugin from 'babel-plugin-recast'; // Not a JS module","symbol":"babel-plugin-recast","correct":"module.exports = { plugins: ['babel-plugin-recast'] };"},{"note":"Options are passed as the second element of an array in Babel config.","wrong":"plugins: ['babel-plugin-recast', { parserOverride: ... }] // Options must be paired with plugin name in array","symbol":"parserOverride","correct":"plugins: [['babel-plugin-recast', { parserOverride: otherPlugin.parserOverride }]]"},{"note":"generatorOverride is not configurable via this plugin.","wrong":"Setting generatorOverride in plugin options","symbol":"generatorOverride","correct":"Not directly exposed; recast handles it internally."}],"quickstart":{"code":"// babel.config.js\nmodule.exports = function (api) {\n  api.cache(true);\n  return {\n    plugins: ['babel-plugin-recast']\n  };\n};\n\n// Run: npx babel input.js --out-file output.js --config-file babel.config.js","lang":"javascript","description":"Basic Babel config enabling babel-plugin-recast to preserve formatting."},"warnings":[{"fix":"If you have another parser override, pass it via options: { parserOverride: otherPlugin.parserOverride }.","message":"Only one plugin can override parsing. Chaining with other parser overrides is possible but untested.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Test source maps after transformation if they are critical.","message":"Recast's source mapping replaces Babel's; may cause unexpected behavior in source maps.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pin recast to 0.x in your package.json.","message":"Peer dependency recast must be 0.x; breaking changes may occur if recast major version updates.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Monitor Babel release notes for changes to these hooks.","message":"Undocumented hooks parserOverride and generatorOverride may break in future Babel versions.","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":"Run npm install --save-dev babel-plugin-recast","cause":"Missing or incorrectly installed package.","error":"Error: Plugin babel-plugin-recast not found"},{"fix":"Run npm install recast@0.x","cause":"Missing peer dependency recast.","error":"Cannot find module 'recast'"},{"fix":"Chain parserOverrides by passing the other plugin's override via options.","cause":"Another plugin also overrides parsing without chaining.","error":"Multiple parser overrides found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}