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+.
npm install babel-plugin-version-transformVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin in .babelrc and use the VERSION placeholder in source code to be replaced by the package.json version.
Use a modern alternative like '@babel/plugin-transform-version' or inline replacement with code transformation.
Ensure VERSION is used as a standalone identifier, not inside strings or as part of larger expressions.
Avoid using the variable name VERSION for other purposes in files where the plugin is active.
Upgrade to a Babel 7 compatible version of the plugin or switch to '@babel/plugin-transform-version'.
Ensure the plugin is listed in .babelrc or the transform call, and that the file is processed by Babel.
Add the corresponding Babel presets (e.g., '@babel/preset-react' for JSX) to your Babel configuration.