rollup-plugin-bundle-hash
raw JSON → 1.0.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that writes output content hashes to a JSON file. Version 1.0.0 is the current stable release with no ongoing update cadence. It differentiates by using hasha for hashing and supporting custom output file paths, but lacks active maintenance or documentation.
Common errors
error Error: Cannot find module 'hasha' ↓
cause Missing hasha dependency.
fix
Run npm install hasha
error TypeError: bundleHash is not a function ↓
cause Incorrect import syntax (CommonJS require on ESM package).
fix
Use ES module import (import bundleHash from 'rollup-plugin-bundle-hash') or enable CJS interop.
error Error: Invalid hash length parameter ↓
cause hashLength must be a positive number between 1 and 64.
fix
Set hashLength to an integer within 1-64.
Warnings
deprecated rollup-plugin-bundle-hash has not been updated in over 3 years; consider using rollup-plugin-hash instead. ↓
fix Switch to rollup-plugin-hash or a more actively maintained plugin.
gotcha The plugin writes hashes only after the generate phase; ensure the bundle output is complete. ↓
fix Use with output.write() or output.generate() after rollup.generate().
gotcha File path is relative to current working directory, not rollup output directory. ↓
fix Provide absolute path or path relative to process.cwd().
Install
npm install rollup-plugin-bundle-hash yarn add rollup-plugin-bundle-hash pnpm add rollup-plugin-bundle-hash Imports
- bundleHash wrong
const bundleHash = require('rollup-plugin-bundle-hash')correctimport bundleHash from 'rollup-plugin-bundle-hash' - bundleHash (named) wrong
import bundleHash from 'rollup-plugin-bundle-hash'correctimport { bundleHash } from 'rollup-plugin-bundle-hash' - Plugin type (TypeScript)
import type { Plugin } from 'rollup'; import bundleHash from 'rollup-plugin-bundle-hash'
Quickstart
import bundleHash from 'rollup-plugin-bundle-hash';
import { rollup } from 'rollup';
rollup({
input: 'src/main.js',
plugins: [
bundleHash({
file: 'dist/hashes.json',
hashLength: 20
})
],
output: {
dir: 'dist',
format: 'es'
}
});