Registry / devops / browserify-persist-fs

browserify-persist-fs

JSON →
library1.2.2jsnpmunverified

A persistent filesystem cache for Browserify that speeds up incremental builds by storing transformation results per file. Version 1.2.2 is the latest stable release; the package is in maintenance mode with no new features expected. It requires a version of Browserify that depends on module-deps >=4.1.0 (e.g., browserify v14.1.0+). Key differentiators: supports garbage collection, logging API for debugging slow builds, and manual cache invalidation via a hashObject. Unlike other caching solutions (e.g., browserify-incremental), it persists to disk so that even CI builds benefit from cached results between runs.

npm install browserify-persist-fs
INSTALL
IMPORT
SIG · BROWSERIFY-PERSIST
B
browserify-persist-fs
devopsjavascriptv1.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default (factory function)
import createPersistFs from 'browserify-persist-fs'
var persistFs = require('browserify-persist-fs')
ESM/CJS both supported. The module exports a factory function that returns a persistentCache object. Must call it with arguments before passing to browserify.
persistentCache option
browserify({ persistentCache: createPersistFs('./.cache', { debug: true }, null, false) })
browserify({ cache: createPersistFs(...) })
Use the 'persistentCache' property, not 'cache'. The factory returns the cache adapter, not a direct cache object.
gc method
const cache = createPersistFs('./.cache', {}); cache.gc({ maxAge: 86400000 }, (err, deleted) => { ... })
gc is a method on the object returned by the factory. It must be called with at least one of maxAge, maxCount, or maxSize.

Shows how to create a persistent cache for Browserify, pass it as option, and perform garbage collection.

import browserify from 'browserify'; import createPersistFs from 'browserify-persist-fs'; const cacheDir = './.cache'; const hashObject = { version: '1.0.0', debug: true }; const persistentCache = createPersistFs(cacheDir, hashObject, null, false); const b = browserify('./entry.js', { persistentCache: persistentCache, debug: true }); b.bundle((err, buf) => { if (err) console.error(err); else console.log('Build completed in', buf.length, 'bytes'); }); // Garbage collection example persistentCache.gc({ maxAge: 7 * 24 * 60 * 60 * 1000 }, (err, deleted) => { if (err) console.error('GC error:', err); else console.log('Deleted', deleted.length, 'stale cache files'); });
Debug
Known issues
breakingbrowserify-persist-fs requires browserify with module-deps >=4.1.0 (i.e., browserify v14.1.0+). Older versions will not work.
fix
Upgrade browserify to v14.1.0 or later.
affects: >=1.0.0
deprecatedThe package is in maintenance mode; no new features or updates are planned. It may not work with future browserify versions.
fix
Consider migrating to browserify-incremental or other alternatives if you need active maintenance.
affects: >=1.0.0
gotchaThe hashObject parameter is required to differentiate builds but its contents are entirely user-defined. Forgetting to update it when configuration changes (transforms, flags) can lead to stale cache hits.
fix
Always include relevant transform versions and configuration flags in the hashObject. Re-run after any change.
affects: >=1.0.0
gotchaNo automatic garbage collection; cache files accumulate indefinitely. You must call the gc() method periodically to avoid disk space exhaustion.
fix
Set up a scheduled task (e.g., cron) or call gc() after each build with sensible limits.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'browserify-persist-fs'
Package not installed or npm install failed.
fix
Run 'npm install browserify-persist-fs --save-dev'
Error: The 'persistentCache' option needs to be an object with a 'get' or 'set' function
The factory function was not called; the module itself was passed directly.
fix
Call the default export: const cache = createPersistFs(...); then pass cache to browserify({ persistentCache: cache }).
TypeError: cache.gc is not a function
gc() is a method on the object returned by the factory, not on the module import.
fix
Store the result of createPersistFs(...) and call gc on that object.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
browserify-persist-fs — npm install browserify-persist-fs · libregistry