rollup-plugin-add-git-msg
raw JSON → 1.1.0 verified Mon Apr 27 auth: no javascript maintenance
Rollup plugin that prepends a banner comment with GIT_TAG and COMMITHASH from the last git commit or tag, along with the repo name, copyright, and compilation date. Current published version is 1.1.0 with no recent updates; appears to be in maintenance mode. Key differentiator: simple, zero-config plugin for adding standard git-based versioning banners to Rollup bundles. Alternatives like rollup-plugin-banner or manual inject plugins offer more flexibility but require more setup.
Common errors
error Error: Cannot find module 'rollup-plugin-add-git-msg' ↓
cause Package not installed or missing from node_modules.
fix
Run
npm install --save-dev rollup-plugin-add-git-msg and ensure it is listed in your package.json. error TypeError: addGitMsg is not a function ↓
cause Incorrect import style: using named import instead of default import.
fix
Use
import addGitMsg from 'rollup-plugin-add-git-msg'; (no braces) or for CommonJS: const addGitMsg = require('rollup-plugin-add-git-msg').default; Warnings
gotcha The plugin will fail silently if executed outside a git repository—no git info is injected and no error is thrown. ↓
fix Ensure the build runs inside a git repository. Consider adding a check or using an alternative plugin that throws errors for missing git info.
gotcha The plugin uses synchronous child_process.execSync to run git commands, which blocks the event loop and may cause performance issues in large builds. ↓
fix For production builds, consider using an asynchronous plugin or running git commands outside the build pipeline.
deprecated Package has not been updated since 2017. May not work with modern Rollup versions (e.g., Rollup 3+). ↓
fix Check compatibility with your Rollup version. For Rollup 3+, you may need to use a more recent alternative like rollup-plugin-banner.
Install
npm install rollup-plugin-add-git-msg yarn add rollup-plugin-add-git-msg pnpm add rollup-plugin-add-git-msg Imports
- addGitMsg wrong
import { addGitMsg } from 'rollup-plugin-add-git-msg';correctimport addGitMsg from 'rollup-plugin-add-git-msg'; - addGitMsg (CommonJS) wrong
const addGitMsg = require('rollup-plugin-add-git-msg');correctconst addGitMsg = require('rollup-plugin-add-git-msg').default; - addGitMsg (TypeScript)
import addGitMsg from 'rollup-plugin-add-git-msg';
Quickstart
import addGitMsg from 'rollup-plugin-add-git-msg';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [
addGitMsg({
copyright: 'MyCompany',
showDate: true,
showTag: true,
showCommitID: true
})
]
};