Registry / devops / babel-plugin-version-inline

babel-plugin-version-inline

JSON →
library1.0.0jsnpmunverified

A Babel plugin that replaces the global constant __VERSION__ with the version string from the project's package.json. Version 1.0.0 is stable but receives no active development; it's a simple compile-time macro for including the package version in code without runtime lookup. Unlike runtime version detection or bundler-specific plugins, this works in any Babel build pipeline. It's unmaintained since 2018 and has no dependencies.

npm install babel-plugin-version-inline
INSTALL
IMPORT
SIG · BABEL-PLUGIN-VERSI
B
babel-plugin-version-inline
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
module.exports = require('babel-plugin-version-inline');
import plugin from 'babel-plugin-version-inline';
This is a Babel plugin, not a typical JS module. It is used via Babel configuration, not imported in user code. ESM import does not work because the plugin uses CommonJS and is not packaged as ESM.
babel config usage
{ "plugins": ["version-inline"] }
{ "plugins": ["babel-plugin-version-inline"] }
In .babelrc or babel.config.js, the plugin name can be shortened to 'version-inline' (without the babel-plugin- prefix) as Babel automatically resolves it.
programmatic API
require('babel-core').transform('code', { plugins: ['version-inline'] })
require('babel-core').transform('code', { plugins: [require('babel-plugin-version-inline')] })
Using the plugin name as a string is sufficient; Babel will resolve the package. Explicit require() may work but is not needed.

Demonstrates how to configure the plugin in .babelrc and how __VERSION__ is replaced with the version from package.json.

// package.json { "name": "my-package", "version": "2.1.0" } // .babelrc { "plugins": ["version-inline"] } // src/index.js const appVersion = __VERSION__; console.log(appVersion); // becomes "2.1.0" // After Babel transformation: // const appVersion = "2.1.0"; // console.log(appVersion);
Debug
Known issues
deprecatedPlugin is no longer maintained; last update in 2018.
fix
Consider using @babel/plugin-transform-version-inline or a custom plugin. Alternatively, bundle version info through other means (e.g., environment variables).
affects: >=1.0.0
gotcha__VERSION__ is replaced at build time; the version string is the one from the project's package.json at the time of build, not at runtime.
fix
Ensure your package.json version is updated before building. No runtime fallback.
affects: >=1.0.0
gotchaThe plugin only replaces __VERSION__ exactly; it does not handle other naming conventions like __VERSION or __version__.
fix
Use __VERSION__ exactly, or fork the plugin to modify the replacement pattern.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: __VERSION__ is not defined
The plugin is not applied (Babel not configured or plugin not installed) or the code is run in an environment where __VERSION__ is not defined.
fix
Install the plugin and add 'version-inline' to your Babel plugins list. If running in Node directly (not built), __VERSION__ will not be defined; ensure you run the compiled output.
Module not found: Can't resolve 'babel-plugin-version-inline'
The plugin is not installed in the project's node_modules or Babel cannot find it.
fix
Run `npm install babel-plugin-version-inline --save-dev` and ensure you are using the correct plugin name in Babel config.
Cannot find module 'babel-plugin-version-inline'
The plugin is not installed or the project's node_modules is missing.
fix
Install the plugin: npm install babel-plugin-version-inline --save-dev
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-version-inline — npm install babel-plugin-version-inline · libregistry