{"id":19239,"library":"babel-plugin-version-inline","title":"babel-plugin-version-inline","description":"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.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/gnandretta/babel-plugin-version-inline","tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-version-inline","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-version-inline","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-version-inline","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import plugin from 'babel-plugin-version-inline';","symbol":"default","correct":"module.exports = require('babel-plugin-version-inline');"},{"note":"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.","wrong":"{\n  \"plugins\": [\"babel-plugin-version-inline\"]\n}","symbol":"babel config usage","correct":"{\n  \"plugins\": [\"version-inline\"]\n}"},{"note":"Using the plugin name as a string is sufficient; Babel will resolve the package. Explicit require() may work but is not needed.","wrong":"require('babel-core').transform('code', { plugins: [require('babel-plugin-version-inline')] })","symbol":"programmatic API","correct":"require('babel-core').transform('code', { plugins: ['version-inline'] })"}],"quickstart":{"code":"// package.json\n{\n  \"name\": \"my-package\",\n  \"version\": \"2.1.0\"\n}\n\n// .babelrc\n{\n  \"plugins\": [\"version-inline\"]\n}\n\n// src/index.js\nconst appVersion = __VERSION__;\nconsole.log(appVersion); // becomes \"2.1.0\"\n\n// After Babel transformation:\n// const appVersion = \"2.1.0\";\n// console.log(appVersion);","lang":"javascript","description":"Demonstrates how to configure the plugin in .babelrc and how __VERSION__ is replaced with the version from package.json."},"warnings":[{"fix":"Consider using @babel/plugin-transform-version-inline or a custom plugin. Alternatively, bundle version info through other means (e.g., environment variables).","message":"Plugin is no longer maintained; last update in 2018.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure your package.json version is updated before building. No runtime fallback.","message":"__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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use __VERSION__ exactly, or fork the plugin to modify the replacement pattern.","message":"The plugin only replaces __VERSION__ exactly; it does not handle other naming conventions like __VERSION or __version__.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"ReferenceError: __VERSION__ is not defined"},{"fix":"Run `npm install babel-plugin-version-inline --save-dev` and ensure you are using the correct plugin name in Babel config.","cause":"The plugin is not installed in the project's node_modules or Babel cannot find it.","error":"Module not found: Can't resolve 'babel-plugin-version-inline'"},{"fix":"Install the plugin: npm install babel-plugin-version-inline --save-dev","cause":"The plugin is not installed or the project's node_modules is missing.","error":"Cannot find module 'babel-plugin-version-inline'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}