Registry / rollup-cache

rollup-cache

JSON →
library2.0.0jsnpmunverified

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.

npm install rollup-cache
INSTALL
IMPORT
SIG · ROLLUP-CACHE
R
rollup-cache
javascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cacheConfig
import { cacheConfig } from 'rollup-cache'
const { cacheConfig } = require('rollup-cache')
ESM import is preferred; the package provides both ESM and CJS builds, but named exports work in both.
Cache
import { Cache } from 'rollup-cache'
import Cache from 'rollup-cache'
Cache is a named export, not default. This is a common mistake.
RollupCachePluginOptions
import type { RollupCachePluginOptions } from 'rollup-cache'
Type import for TypeScript users; not available in CJS.

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.

import { cacheConfig, Cache } from 'rollup-cache'; const cache = new Cache(); const rollupConfig = { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ { name: 'my-plugin', resolveId(id) { if (id === 'virtual-module') { return '\0virtual'; } return null; }, load(id) { if (id === '\0virtual') { const cached = cache.get(id); if (cached) return cached; const code = 'export default 42;'; cache.set(id, code); return code; } return null; } }, cacheConfig({ cache }) ] }; export default rollupConfig;
Debug
Known issues
breakingv2.0.0 requires Rollup v3; not compatible with Rollup v2.
fix
Use rollup-cache v1.x with Rollup v2, or upgrade Rollup to v3.
affects: >=2.0.0
deprecatedv1.2.0 introduced CommonJS build but type definitions may not resolve correctly in all CJS setups.
fix
Use ESM import to avoid type resolution issues, or pin exact version.
affects: >=1.2.0 <2.0.0
gotchaCache is not a named export in v1.x? It was added in v1.1.0? Verify exports per version.
fix
Upgrade to v1.1.0 or later, or use internal cache manually.
affects: <1.1.0
Errors
Common errors & fixes
Cannot find module 'rollup-cache' or its corresponding type declarations.
Missing npm install or wrong module resolution: package.json 'exports' field may not cover all entry points.
fix
Ensure rollup-cache is installed: npm install rollup-cache. Use import from 'rollup-cache' not a subpath.
rollup-cache: Rollup version mismatch. Expected >=3.0.0, got 2.x.
Using rollup-cache v2 with Rollup v2.
fix
Upgrade Rollup to v3 or downgrade rollup-cache to v1.x: npm install rollup-cache@1
export 'Cache' (imported as 'Cache') was not found in 'rollup-cache'
Importing 'Cache' as a named export from a version that doesn't have it (pre-v1.1.0).
fix
Upgrade to rollup-cache v1.1.0 or later: npm install rollup-cache@latest
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency for Rollup v3 plugin API
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-cache — npm install rollup-cache · libregistry