{"id":15412459,"url":"https://github.com/robertknight/rollup-cache","last_synced_at":"2025-07-20T15:33:50.328Z","repository":{"id":45698400,"uuid":"422409418","full_name":"robertknight/rollup-cache","owner":"robertknight","description":"Disk caching to speed up Rollup builds","archived":false,"fork":false,"pushed_at":"2023-06-26T22:17:33.000Z","size":905,"stargazers_count":20,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T13:43:26.976Z","etag":null,"topics":["rollup"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertknight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-10-29T01:48:43.000Z","updated_at":"2024-07-24T01:36:00.000Z","dependencies_parsed_at":"2024-10-19T17:46:54.177Z","dependency_job_id":"2b8d6b56-e00d-4786-95bc-972fc2b459c5","html_url":"https://github.com/robertknight/rollup-cache","commit_stats":{"total_commits":29,"total_committers":3,"mean_commits":9.666666666666666,"dds":0.4482758620689655,"last_synced_commit":"6d86bee76d3c9cc2e9e60e66312a080eb43dee51"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/robertknight/rollup-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertknight%2Frollup-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertknight%2Frollup-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertknight%2Frollup-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertknight%2Frollup-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertknight","download_url":"https://codeload.github.com/robertknight/rollup-cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertknight%2Frollup-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266151526,"owners_count":23884436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["rollup"],"created_at":"2024-10-01T16:53:18.288Z","updated_at":"2025-07-20T15:33:50.297Z","avatar_url":"https://github.com/robertknight.png","language":"JavaScript","readme":"# rollup-cache\n\nThis package provides tools to speed up repeated [Rollup](https://rollupjs.org)\nbundle builds by caching steps of the build process to disk.\n\n## Comparison to Rollup's built-in caching\n\nRollup has a built-in cache used to speed up incremental builds in `watch`\nmode. This is an in-memory cache that is lost each time Rollup is restarted\nhowever. `rollup-cache` speeds up the initial build and builds which do not\nuse `watch` mode by using a disk cache.\n\n## How it works\n\nThis package implements two kinds of caching: **plugin caching** and **prebuilding**.\n\n### Plugin caching\n\nThe package adds caching for the loading and transforming of code done by\nRollup plugins. By default it is enabled only for official Rollup plugins with\nwhich it is compatible and where it can significantly speed up builds:\n\n- @rollup/plugin-commonjs\n- @rollup/plugin-node-resolve\n- @rollup/plugin-babel\n\nYou can specify other plugins via the `cachePlugins` config option, but be\naware that this may not work for all plugins.\n\n### Prebuilding\n\nFor every JavaScript module included in a bundle, Rollup has to do work to\nparse the code, analyze the result and write the contents to the output.\n\nFor npm dependencies which do not change between most builds, this\ncan be avoided by building the npm package into a bundle which is then referenced\nfrom your application bundle. Conceptually this is similar to shared libraries\n(aka DLLs) in native applications.\n\nFor example, supposing you have a Rollup config that builds `output/app.bundle.js`\nfrom the following entry module:\n\n```js\nimport { doComplexThing } from 'big-library';\n\ndoComplexThing(...);\n```\n\nEnabling prebuilding of `big-library` would result in the following in the\noutput bundle:\n\n```js\nimport { doComplexThing } from './npm/big-library.bundle.js';\n\ndoComplexThing(...);\n```\n\nThe `big-library` package would be bundled as an ES module in `output/npm/big-library.bundle.js`.\nEach time your Rollup build runs, the timestamp of `big-library`'s package.json\nfile will be checked and the `big-library.bundle.js` bundle will be rebuilt if\nit has changed.\n\nIn order to use this feature, your application or library bundle must be built\nas an ES module (set `output.format` to `es` in the bundle config) and loaded\nusing `\u003cscript type=\"module\" …\u003e` in your HTML. You will also need to make sure\nthat the tool you are using to serve your assets allows the prebuilt bundles\nto be fetched.\n\n## Installation\n\nIf you are using npm:\n\n```sh\nnpm install --save-dev rollup-cache\n```\n\nOr for Yarn:\n\n```sh\nyarn add --dev rollup-cache\n```\n\n## Usage\n\nTo enable caching for a bundle, wrap its configuration in a call to `cacheBuild`.\nFor example, given a Rollup config file `rollup.config.js`:\n\n```js\nexport default {\n  input: { ... },\n  output: { ... },\n  plugins: [...],\n}\n```\n\nCaching can be added using:\n\n```js\nimport { cacheBuild } from 'rollup-cache';\n\nconst cacheConfig = {\n  name: 'my-app',\n  dependencies: ['rollup.config.js'],\n  prebuild: ['big-library'],\n};\n\nexport default cacheBuild(cacheConfig, {\n  input: { ... },\n  output: { ... },\n  plugins: [...],\n})\n```\n\nThe `name` option specifies a name for the cache to use. This should be different\nfor each bundle.\n\nIf any of the files listed in the `dependencies` option have changed since the\nprevious build, then the existing cache will be discarded.\n\n`prebuild` specifies a list of npm packages to prebuild as separate npm bundles.\nIf omitted, prebuilding will be disabled.\n\n## Configuration\n\n### General options\n\n- `name` specifies a unique name for the cache data. This should be different\n  for each bundle.\n\n- `enabled` specifies whether caching should be used for the current build.\n  By default this is false for production builds, indicated by the `NODE_ENV`\n  environment variable being set to `production`, or true otherwise. It is\n  recommended to **disable caching for production builds** to reduce the risk\n  of stale cache data being used.\n\n### Plugin caching options\n\n- `cacheDir` specifies a location to write cache files to. _Default: \"node_modules/.cache/rollup-cache\"_\n\n- `cachePlugins` specifies a list of plugins to cache. _Default:\n  `[\"babel\", \"commonjs\", \"node-resolve\"]`._\n\n  It is recommended to only enable caching for \"heavy\" plugins that do a lot of\n  work. Caching may not work for all plugins.\n\n- `dependencies` is a list of file paths whose contents should be used to\n  determine whether to reuse cached results from previous builds. If any of these\n  files have changed since the previous build, cached data will be ignored. In\n  addition to the files listed here, the following files are automatically\n  included:\n\n  - Package metadata: `package.json`\n  - Lockfiles: `package-lock.json`, `yarn.lock`\n\n### Prebuild options\n\n- `prebuildDir` specifies a directory to create pre-built npm dependencies in,\n  relative to the output directory of the bundle. _Default: \"./npm\"_\n\n- `prebuild` is a list of npm dependencies or patterns that should be prebuilt\n  if they are used by the bundle. For various reasons prebuilding may not work\n  with all dependencies, and is generally only valuable for large dependencies.\n  Therefore the dependencies to consider for prebuilding have to be listed explicitly.\n\n  The recommended approach to using this option is to start with an empty\n  `prebuild` list and then incrementally add your largest dependencies to it.\n  If you encounter an error building the bundle or loading your application,\n  skip that dependency.\n\n## Clearing the cache\n\nCache data is written to `node_modules/.cache/rollup-cache` by default, or\nthe location specified by the `cacheDir` option otherwise.\n\nTo clear the cache explicitly, remove all files in this directory. If your build\nscripts have a `clean` task that remove all existing build assets etc, you may\nwant to add the cache directory to it.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertknight%2Frollup-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertknight%2Frollup-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertknight%2Frollup-cache/lists"}