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.

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.
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().
npm install rollup-plugin-bundle-hash
yarn add rollup-plugin-bundle-hash
pnpm add rollup-plugin-bundle-hash

Shows basic setup of rollup-plugin-bundle-hash with rollup, outputting hashes to dist/hashes.json.

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'
  }
});