{"id":15383147,"url":"https://github.com/jhildenbiddle/rollup-plugin-source-hash","last_synced_at":"2026-03-12T14:18:56.143Z","repository":{"id":239647751,"uuid":"796797699","full_name":"jhildenbiddle/rollup-plugin-source-hash","owner":"jhildenbiddle","description":"A rollup.js plugin that inserts hash values based on pre-bundled source code into filenames and bundled code.","archived":false,"fork":false,"pushed_at":"2024-05-15T16:08:41.000Z","size":94,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-02T10:06:06.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhildenbiddle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jhildenbiddle"}},"created_at":"2024-05-06T16:43:07.000Z","updated_at":"2024-08-15T02:47:27.000Z","dependencies_parsed_at":"2024-10-18T15:29:51.580Z","dependency_job_id":null,"html_url":"https://github.com/jhildenbiddle/rollup-plugin-source-hash","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.1071428571428571,"last_synced_commit":"b614dd66539d0f17197bc6b64b995ad3b18c6452"},"previous_names":["jhildenbiddle/rollup-plugin-source-hash"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jhildenbiddle/rollup-plugin-source-hash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhildenbiddle%2Frollup-plugin-source-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhildenbiddle%2Frollup-plugin-source-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhildenbiddle%2Frollup-plugin-source-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhildenbiddle%2Frollup-plugin-source-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhildenbiddle","download_url":"https://codeload.github.com/jhildenbiddle/rollup-plugin-source-hash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhildenbiddle%2Frollup-plugin-source-hash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30428036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:00:25.264Z","status":"ssl_error","status_checked_at":"2026-03-12T13:59:52.690Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T14:35:31.975Z","updated_at":"2026-03-12T14:18:56.124Z","avatar_url":"https://github.com/jhildenbiddle.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jhildenbiddle"],"categories":["Plugins"],"sub_categories":["Output"],"readme":"# rollup-plugin-source-hash\n\n[![NPM](https://img.shields.io/npm/v/rollup-plugin-source-hash.svg?style=flat-square)](https://www.npmjs.com/package/rollup-plugin-source-hash)\n[![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/jhildenbiddle/rollup-plugin-source-hash/test.yml?branch=main\u0026label=checks\u0026style=flat-square)](https://github.com/jhildenbiddle/rollup-plugin-source-hash/actions?query=branch%3Amain+)\n[![Codacy code quality](https://img.shields.io/codacy/grade/d3ea7fdae22f46fe855d5c2435b03e2a/main?style=flat-square)](https://app.codacy.com/gh/jhildenbiddle/rollup-plugin-source-hash/dashboard?branch=main)\n[![Codacy branch coverage](https://img.shields.io/codacy/coverage/d3ea7fdae22f46fe855d5c2435b03e2a/main?style=flat-square)](https://app.codacy.com/gh/jhildenbiddle/rollup-plugin-source-hash/dashboard?branch=main)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://github.com/jhildenbiddle/rollup-plugin-source-hash/blob/main/LICENSE)\n[![Sponsor this project](https://img.shields.io/static/v1?style=flat-square\u0026label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/jhildenbiddle)\n\nA [rollup.js](https://rollupjs.org) plugin that inserts hash values based on pre-bundled source code into filenames and bundled code.\n\n## Features\n\n- Generates hash values based on pre-bundled source code\n- Inserts hash values in bundle code and filenames\n- Supports custom placeholders\n- Deletes outdated bundles on each build (optional)\n\n## Why?\n\nRollup's built-in [`[hash]`](https://rollupjs.org/configuration-options/#output-entryfilenames) naming option and various hash-related [plugins](https://github.com/phamann/rollup-plugin-hash) generate hash values based on the bundled output. This means bundles created from the same source that use different rollup configurations (output format, transpilation, minification, comments, etc.) will generate different hash values:\n\n```shell\n# Rollup [hash] and other plugins\n# Same source code, different hash for each file\nbundle-742cd4.cjs\nbundle-ddc4fb.js\nbundle-8023f4.min.js\nbundle-c463f6.mjs\n```\n\nThis plugin generates hash values based on the source code _before_ Rollup has completed its bundling process. As a result, bundles created from the same source code will generate the same hash value regardless of the rollup configuration used to create them. This hash value serves as a build ID, easily identifying all bundles generated from the same source code:\n\n```shell\n# This plugin\n# Same source code, same hash for each file\nbundle-742cd4.cjs\nbundle-742cd4.js\nbundle-742cd4.min.js\nbundle-742cd4.mjs\n```\n\nThis plugin can also inject a generated hash value into the bundled output:\n\n```js\n// Source\nconst hash = '__SOURCEHASH__'; // Default\n```\n\n```js\n// Bundle output\nconst hash = '742cd4';\n```\n\n## Installation\n\n**NPM**\n\n```bash\nnpm install --save-dev rollup-plugin-source-hash\n```\n\n## Usage\n\n```js\n// Rollup configuration\nimport sourceHash from 'rollup-plugin-source-hash';\n\nexport default {\n  input: 'main.js',\n  output: {\n    file: 'bundle-[sourcehash].js' // Default\n  },\n  plugins: [\n    sourceHash({\n      // Options...\n    })\n  ]\n};\n```\n\nThe [filePlaceholder](#fileplaceholder) value will be replaced with the generated source hash:\n\n```shell\n# Bundle file\nbundle-742cd4.js\n```\n\nAll [codePlaceholders](#codeplaceholder) will be replaced with the generated source hash:\n\n```js\n// Source: main.js\nconst hash = '__SOURCEHASH__'; // Default\n```\n\n```js\n// Bundle: bundle-742cd4.js\nconst hash = '742cd4';\n```\n\n## Options\n\n### autoDelete\n\n- Type: `boolean`\n- Default: `true`\n\nDetermines if previous builds will be automatically deleted when new builds are generated.\n\n```js\nsourceHash({\n  autoDelete: true // Default\n});\n```\n\nThe plugin will search for previous builds in the same output directory and match files based on the name pattern and hash value length. For example, if a name pattern of `\"bundle-[sourcehash].js\"` is used to generate a new bundle named `bundle-742cd4.js`, all files that start with `bundle-`, are followed by an eight character alphanumeric value, and end with `.js` will be deleted.\n\n```js\n// Rollup configuration\noutput: {\n  file: 'bundle-[sourcehash].js'; // Default\n}\n```\n\n```shell\n# Bundle file\nbundle-742cd4.js\n```\n\n```shell\n# These files will be deleted\nbundle-ddc4fb.js\nbundle-8023f4.js\nbundle-c463f6.js\n\n# These files will not be deleted\nbundle.js\nbundle-acbd18db4cc2f85cedef654fccc4a4d8.js\n```\n\n### codePlaceholder\n\n- Type: `string`\n- Default: `\"__SOURCEHASH__\"`;\n\nThe source code placeholder string to replace with the generated hash value.\n\n```js\nsourceHash({\n  codePlaceholder: '__SOURCEHASH__'\n});\n```\n\n### filePlaceholder\n\n- Type: `string`\n- Default: `\"[sourcehash]\"`\n\nThe bundle file name placeholder string to replace with the generated hash value.\n\n```js\nsourceHash({\n  filePlaceholder: '[sourcehash]'\n});\n```\n\n### hashArgs\n\n- Type: `array|string`\n- Default: `[\"shake256\", { outputLength: 3 }]`\n\nThe arguments to pass to Node's [crypto.createHash](https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options) method.\n\n```js\n// Array\nsourceHash({\n  hashArgs: ['shake256', { outputLength: 3 }]\n});\n\n// String\nsourceHash({\n  hashArgs: 'md5'\n});\n```\n\nFrom the Node.js [createHash](https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options) documentation:\n\n\u003e The `algorithm` is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. On recent releases of OpenSSL, `openssl list -digest-algorithms` will display the available digest algorithms.\n\u003e\n\u003e For XOF hash functions such as `'shake256'`, the `outputLength` option can be used to specify the desired output length in bytes.\n\n## Sponsorship\n\nA [sponsorship](https://github.com/sponsors/jhildenbiddle) is more than just a way to show appreciation for the open-source authors and projects we rely on; it can be the spark that ignites the next big idea, the inspiration to create something new, and the motivation to share so that others may benefit.\n\nIf you benefit from this project, please consider lending your support and encouraging future efforts by [becoming a sponsor](https://github.com/sponsors/jhildenbiddle).\n\nThank you! 🙏🏻\n\n## Contact \u0026 Support\n\n- Follow 👨🏻‍💻 **@jhildenbiddle** on [Twitter](https://twitter.com/jhildenbiddle) and [GitHub](https://github.com/jhildenbiddle) for announcements\n- Create a 💬 [GitHub issue](https://github.com/jhildenbiddle/rollup-plugin-source-hash/issues) for bug reports, feature requests, or questions\n- Add a ⭐️ [star on GitHub](https://github.com/jhildenbiddle/rollup-plugin-source-hash) and 🐦 [tweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fjhildenbiddle%2Frollup-plugin-source-hash\u0026hashtags=css,developers,frontend,javascript) to promote the project\n- Become a 💖 [sponsor](https://github.com/sponsors/jhildenbiddle) to support the project and future efforts\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/jhildenbiddle/rollup-plugin-source-hash/blob/main/LICENSE) for details.\n\nCopyright (c) John Hildenbiddle ([@jhildenbiddle](https://twitter.com/jhildenbiddle))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhildenbiddle%2Frollup-plugin-source-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhildenbiddle%2Frollup-plugin-source-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhildenbiddle%2Frollup-plugin-source-hash/lists"}