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.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

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.

module.exports = require('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.

{ "plugins": ["version-inline"] }

Using the plugin name as a string is sufficient; Babel will resolve the package. Explicit require() may work but is not needed.

require('babel-core').transform('code', { plugins: ['version-inline'] })

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 footguns
deprecatedPlugin is no longer maintained; last update in 2018.
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.
gotchaThe plugin only replaces __VERSION__ exactly; it does not handle other naming conventions like __VERSION or __version__.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources