{"id":19241,"library":"babel-plugin-version-transform","title":"babel-plugin-version-transform","description":"A Babel plugin (v1.0.0, stable, low release cadence) that replaces the identifier VERSION with the stringified version number from package.json during compilation. This is a specialized transform plugin that enables compile-time injection of package version without runtime overhead. Unlike environment variable approaches, this plugin works at the AST level within Babel's plugin pipeline. It is unmaintained since 2017 and relies on Babel 6 APIs, making it incompatible with Babel 7+.","status":"deprecated","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/blainekasten/babel-plugin-version-transform","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-version-transform","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-version-transform","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-version-transform","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Babel 6 or earlier; not compatible with Babel 7+","package":"babel-core","optional":false}],"imports":[{"note":"Plugin is specified by string name in .babelrc or programmatic config","wrong":"plugins: [require('babel-plugin-version-transform')]","symbol":"default (plugin)","correct":"plugins: ['version-transform']"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\"version-transform\"]\n}\n\n// source.js\nimport pkg from './package.json';\nfunction log(data) {\n  xhr({...data, version: VERSION});\n}","lang":"javascript","description":"Shows how to configure the plugin in .babelrc and use the VERSION placeholder in source code to be replaced by the package.json version."},"warnings":[{"fix":"Use a modern alternative like '@babel/plugin-transform-version' or inline replacement with code transformation.","message":"Plugin only works with Babel 6; not compatible with Babel 7+","severity":"deprecated","affected_versions":"all"},{"fix":"Ensure VERSION is used as a standalone identifier, not inside strings or as part of larger expressions.","message":"The plugin only replaces the bare identifier VERSION, not string literals or computed expressions.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid using the variable name VERSION for other purposes in files where the plugin is active.","message":"VERSION is a global replacement; any identifier named VERSION in scope will be replaced.","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":"Upgrade to a Babel 7 compatible version of the plugin or switch to '@babel/plugin-transform-version'.","cause":"Using the plugin with Babel 7+ which expects function-form plugins.","error":"Error: Plugin/preset files are not allowed to export objects, only functions."},{"fix":"Ensure the plugin is listed in .babelrc or the transform call, and that the file is processed by Babel.","cause":"The plugin did not replace VERSION because it was not executed (e.g., missing plugin configuration).","error":"ReferenceError: VERSION is not defined"},{"fix":"Add the corresponding Babel presets (e.g., '@babel/preset-react' for JSX) to your Babel configuration.","cause":"Using the plugin with unsupported syntax (e.g., JSX, TypeScript) without the appropriate Babel presets.","error":"SyntaxError: Unexpected token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}