Registry / devops / babel-plugin-version-transform

babel-plugin-version-transform

JSON →
library1.0.0jsnpmunverified

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-transform
INSTALL
IMPORT
SIG · BABEL-PLUGIN-VERSI
B
babel-plugin-version-transform
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
plugins: ['version-transform']
plugins: [require('babel-plugin-version-transform')]
Plugin is specified by string name in .babelrc or programmatic config

Shows how to configure the plugin in .babelrc and use the VERSION placeholder in source code to be replaced by the package.json version.

// .babelrc { "plugins": ["version-transform"] } // source.js import pkg from './package.json'; function log(data) { xhr({...data, version: VERSION}); }
Debug
Known issues
deprecatedPlugin only works with Babel 6; not compatible with Babel 7+
fix
Use a modern alternative like '@babel/plugin-transform-version' or inline replacement with code transformation.
affects: all
gotchaThe plugin only replaces the bare identifier VERSION, not string literals or computed expressions.
fix
Ensure VERSION is used as a standalone identifier, not inside strings or as part of larger expressions.
affects: >=0.0.0
gotchaVERSION is a global replacement; any identifier named VERSION in scope will be replaced.
fix
Avoid using the variable name VERSION for other purposes in files where the plugin is active.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Plugin/preset files are not allowed to export objects, only functions.
Using the plugin with Babel 7+ which expects function-form plugins.
fix
Upgrade to a Babel 7 compatible version of the plugin or switch to '@babel/plugin-transform-version'.
ReferenceError: VERSION is not defined
The plugin did not replace VERSION because it was not executed (e.g., missing plugin configuration).
fix
Ensure the plugin is listed in .babelrc or the transform call, and that the file is processed by Babel.
SyntaxError: Unexpected token
Using the plugin with unsupported syntax (e.g., JSX, TypeScript) without the appropriate Babel presets.
fix
Add the corresponding Babel presets (e.g., '@babel/preset-react' for JSX) to your Babel configuration.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
babel-corerequiredRequires Babel 6 or earlier; not compatible with Babel 7+
Agent activity
8 hits · last 30 days
node
8
Resources
babel-plugin-version-transform — npm install babel-plugin-version-transform · libregistry