{"id":21888,"library":"rollup-cache","title":"rollup-cache","description":"Caching utilities for Rollup build plugins. Current version 2.0.0 requires Rollup v3 (breaking change from v1.x which targeted Rollup v2). Provides cacheConfig() and Cache class to persist and reuse expensive computation results across builds, improving incremental build performance. Key differentiator: designed specifically for Rollup plugin ecosystem with cache key generation and invalidation similar to Rollup's own caching. Releases are infrequent; maintenance seems low. Ships TypeScript types. ESM and CommonJS builds available.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/robertknight/rollup-cache","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-cache","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Rollup v3 plugin API","package":"rollup","optional":false}],"imports":[{"note":"ESM import is preferred; the package provides both ESM and CJS builds, but named exports work in both.","wrong":"const { cacheConfig } = require('rollup-cache')","symbol":"cacheConfig","correct":"import { cacheConfig } from 'rollup-cache'"},{"note":"Cache is a named export, not default. This is a common mistake.","wrong":"import Cache from 'rollup-cache'","symbol":"Cache","correct":"import { Cache } from 'rollup-cache'"},{"note":"Type import for TypeScript users; not available in CJS.","wrong":null,"symbol":"RollupCachePluginOptions","correct":"import type { RollupCachePluginOptions } from 'rollup-cache'"}],"quickstart":{"code":"import { cacheConfig, Cache } from 'rollup-cache';\n\nconst cache = new Cache();\n\nconst rollupConfig = {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'esm' },\n  plugins: [\n    {\n      name: 'my-plugin',\n      resolveId(id) {\n        if (id === 'virtual-module') {\n          return '\\0virtual';\n        }\n        return null;\n      },\n      load(id) {\n        if (id === '\\0virtual') {\n          const cached = cache.get(id);\n          if (cached) return cached;\n          const code = 'export default 42;';\n          cache.set(id, code);\n          return code;\n        }\n        return null;\n      }\n    },\n    cacheConfig({ cache })\n  ]\n};\n\nexport default rollupConfig;","lang":"typescript","description":"Shows how to create a Cache instance, wrap Rollup config with cacheConfig() to persist cache across builds, and use the cache inside a custom plugin's load hook."},"warnings":[{"fix":"Use rollup-cache v1.x with Rollup v2, or upgrade Rollup to v3.","message":"v2.0.0 requires Rollup v3; not compatible with Rollup v2.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use ESM import to avoid type resolution issues, or pin exact version.","message":"v1.2.0 introduced CommonJS build but type definitions may not resolve correctly in all CJS setups.","severity":"deprecated","affected_versions":">=1.2.0 <2.0.0"},{"fix":"Upgrade to v1.1.0 or later, or use internal cache manually.","message":"Cache is not a named export in v1.x? It was added in v1.1.0? Verify exports per version.","severity":"gotcha","affected_versions":"<1.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure rollup-cache is installed: npm install rollup-cache. Use import from 'rollup-cache' not a subpath.","cause":"Missing npm install or wrong module resolution: package.json 'exports' field may not cover all entry points.","error":"Cannot find module 'rollup-cache' or its corresponding type declarations."},{"fix":"Upgrade Rollup to v3 or downgrade rollup-cache to v1.x: npm install rollup-cache@1","cause":"Using rollup-cache v2 with Rollup v2.","error":"rollup-cache: Rollup version mismatch. Expected >=3.0.0, got 2.x."},{"fix":"Upgrade to rollup-cache v1.1.0 or later: npm install rollup-cache@latest","cause":"Importing 'Cache' as a named export from a version that doesn't have it (pre-v1.1.0).","error":"export 'Cache' (imported as 'Cache') was not found in 'rollup-cache'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}