Registry / devops / rollup-plugin-build-git-version

rollup-plugin-build-git-version

JSON →
library0.0.9jsnpmunverified

A Rollup plugin that generates a version.json file containing git information (branch, commit id, time, message, author) and build time during the bundle process. Current version 0.0.9 is stable but likely early-stage; release cadence is unknown. Key differentiator: provides structured git metadata directly in the output, useful for CI/CD pipelines and runtime version display. Supports Node >=16 and pnpm 8.x. Ships TypeScript types. Note that the plugin uses require() in its own example, but Rollup encourages ESM imports.

npm install rollup-plugin-build-git-version
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-BUIL
R
rollup-plugin-build-git-version
devopsjavascriptv0.0.9
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

buildGitVersion
import { buildGitVersion } from 'rollup-plugin-build-git-version'
const buildGitVersion = require('rollup-plugin-build-git-version')
Plugin uses ESM named export; require() may fail in ESM contexts or with Rollup's ESM-first approach.
default
import buildGitVersion from 'rollup-plugin-build-git-version'
import { default as buildGitVersion } from 'rollup-plugin-build-git-version'
Plugin does not have a default export; using default import will result in undefined or error.
buildGitVersion type
import type { BuildGitVersion } from 'rollup-plugin-build-git-version'
import { BuildGitVersion } from 'rollup-plugin-build-git-version'
Type is not exported; use typeof import(...) for custom types if needed.

This example shows how to integrate the plugin into a Rollup configuration, generating version.json in the output directory.

import { buildGitVersion } from 'rollup-plugin-build-git-version'; import { defineConfig } from 'rollup'; export default defineConfig({ input: 'src/index.js', output: { dir: 'dist', format: 'cjs' }, plugins: [buildGitVersion()] });
Debug
Known issues
gotchaThe plugin example uses CommonJS require() but the package is ESM-only (has type: 'module' or uses ESM syntax).
fix
Use import { buildGitVersion } from 'rollup-plugin-build-git-version'.
affects: >0.0.1
gotchaThe generated version.json always overwrites the output; there is no option to merge with existing file.
fix
Consider using before/after hooks or custom plugin to merge if needed.
affects: >=0.0.0
breakingPlugin requires Node >=16 and pnpm >=8. Using older versions may fail due to unsupported APIs.
fix
Update Node to >=16, or use an alternative if stuck on older Node.
affects: >=0.0.9
gotchaThe version.json is created at the root of the output directory; cannot change path without workaround.
fix
Use Rollup's manual output or another plugin to move the file post-build.
affects: <1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-build-git-version'
Package not installed or missing devDependency.
fix
npm install --save-dev rollup-plugin-build-git-version
TypeError: buildGitVersion is not a function
Using default import instead of named import.
fix
Use import { buildGitVersion } from 'rollup-plugin-build-git-version'.
SyntaxError: Unexpected token 'export'
Using require() with an ESM-only package.
fix
Switch to import syntax or use dynamic import().
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
rollup-plugin-build-git-version — npm install rollup-plugin-build-git-version · libregistry