A Babel plugin that replaces occurrences of the string literal or identifier `__VERSION__` with the version string from `package.json` (e.g., `"0.2.3"`). Current stable version 0.2.3 enables compile-time version injection. The plugin can be configured to use a custom define name and to toggle replacement of identifiers vs. string literals. This is a lightweight zero-dependency tool for build processes using Babel for JavaScript/TypeScript projects.
npm install babel-plugin-versionVerified import paths — ran on the pinned version, not inferred.
A Babel plug-in that replaces __VERSION__ tokens with the version from package.json at build time.
Ensure __VERSION__ is used as a standalone identifier or a string literal (e.g., `const v = __VERSION__;` or `"__VERSION__"`).
Ensure that Babel runs in the context of your project root where package.json exists.
Consider migrating to @rollup/plugin-replace for Rollup, or use DefinePlugin for webpack, or simply read process.env.npm_package_version at runtime if version is needed.
Run: npm install --save-dev babel-plugin-version
Ensure package.json exists in the Babel working directory and contains a 'version' string.
Use the correct nested array syntax: ['version', { options }] inside the plugins array.No dependency data recorded yet.