{"id":15646442,"url":"https://github.com/martinheidegger/browserify-persist-fs","last_synced_at":"2025-04-30T12:23:07.848Z","repository":{"id":143866038,"uuid":"80812214","full_name":"martinheidegger/browserify-persist-fs","owner":"martinheidegger","description":"Efficient \u0026 stable persistent filesystem cache for browserify","archived":false,"fork":false,"pushed_at":"2018-02-19T03:08:59.000Z","size":23,"stargazers_count":16,"open_issues_count":3,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T13:36:17.646Z","etag":null,"topics":["browserify","build-pipelines","frontend","speed"],"latest_commit_sha":null,"homepage":null,"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/martinheidegger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2017-02-03T08:47:06.000Z","updated_at":"2021-01-20T08:41:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f8a7223-fd26-41e3-8ccf-276e5ae51ac1","html_url":"https://github.com/martinheidegger/browserify-persist-fs","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fbrowserify-persist-fs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fbrowserify-persist-fs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fbrowserify-persist-fs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fbrowserify-persist-fs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinheidegger","download_url":"https://codeload.github.com/martinheidegger/browserify-persist-fs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251700976,"owners_count":21629848,"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":["browserify","build-pipelines","frontend","speed"],"created_at":"2024-10-03T12:12:55.060Z","updated_at":"2025-04-30T12:23:07.795Z","avatar_url":"https://github.com/martinheidegger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 A Browserify Cache for Maximum speed.\n\n[![Build Status](https://travis-ci.org/martinheidegger/browserify-persist-fs.svg?branch=master)](https://travis-ci.org/martinheidegger/browserify-persist-fs)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n[![Coverage Status](https://coveralls.io/repos/github/martinheidegger/browserify-persist-fs/badge.svg)](https://coveralls.io/github/martinheidegger/browserify-persist-fs)\n\n`browserify-persist-fs` stores the computation results for every file\nprocessed in a `cache` folder which makes recomputation of previous executions\nextremely fast _(particularily useful for CI!)_.\n\n**Oh**❗️ It also comes with a logging API that can help you figure out why\nyour browserify execution is slow and which files cost most time!\n\n\u003e In our production we were able to reduce repeated requests from 40s → 6s 🎉\n\n## Temporary disclaimer\n\nIn order to user `browserify-persist-fs` you need to have a version of browserify\nthat depends on [`module-deps`](https://github.com/substack/module-deps) with a\nversion \u003e= 4.1.0 installed.\n\nBy installing a clean version of browserify v14.1.0 or newer,\nyou will get the required `module-deps` version.\n\n## Installation \u0026 Setup\n\nSpecify `browserify-persist-fs` as `persistentCache` option.\n\n```javascript\nconst browserify = require('@leichtgewicht/browserify') // for the time being...\nconst browserifyPersistFs = require('browserify-persist-fs')(\n  '.cache', // The folder where things should be stored\n  {},       // \"hashObject\": And object that is used to figure out if the configuration has changed\n  null,     // Optional log handler (default: null)\n  false     // Pass in true to disable the cache (default: false)\n)\nconst bundle = browserify({\n  persistentCache: browserifyPersistFs\n})\n```\n\n## Identity of builds\n\nWhen you build something with browserify you can have a lot of ways in to modify\nthe resulting output: `transforms`, `debug`, `sourcemap`, etc. Since it is\nimpossible to figure out automatically what properties may exist, **you have to\nspecify how the build is different**.\n\nThe second property, the `hashObject`, should be used to make sure that different\nconfigurations of browserify don't use the same cache directory.\n\nUsually it contains a mixture of version specifications and config flags:\n\n```javascript\nconst browserifyPersistFs = require('browserify-persist-fs')('.cache',\n  {\n    debug: true,\n    transforms: [\n      require('browserify/package.json').version,\n      require('browserify-shim/package.json').version\n      require('uglifyify/package.json').version\n    ]\n  }\n)\n```\n\nMake sure that this results in a good idea to ensure developer happiness ☀️ 🙆\n\n_A [PR](https://github.com/martinheidegger/browserify-persist-fs) to make this\nprocess better would be highly welcome._\n\n## Garbage Collection\n\n`browserify-persist-fs` does not automatically delete old cache files. You will\nrun out of disk space if the old files are not regularly deleted.\n\n`browserify-persist-fs` offers an API that allows you to delete old files:\n\n```javascript\nconst browserifyPersistFs = require('browserify-persist-fs')('.cache', { /*...*/ })\nbrowserifyPersistFs.gc({\n  maxAge: 100000, // Age of a file in milliseconds (Default: Number.MAX_SAFE_INTEGER)\n  maxCount: 10000, // Maximum count of files in the cache folder (Default: Number.MAX_SAFE_INTEGER)\n  maxSize: 10000, // Maximum size in bytes that all files accumulatively might have (Default: Number.MAX_SAFE_INTEGER)\n  parallel: 10 // Maximum parallel processes to run (Default: 20)\n}, function (err, deletedFiles) {\n  // deletedFiles holds the path of all files that got deleted\n})\n```\n\nYou have to specify at least `maxAge`, `maxCount` or `maxSize`. Any combination\nis possible as well.\n\n## Logging\n\n```javascript\nconst browserifyPersistFs = require('browserify-persist-fs')('.cache', {},\n  log\n)\n\nfunction log (entry) {\n  entry.file // File that has been loaded\n  entry.err  // In case an error occurred\n  entry.cacheFile // The cache file location that has been used\n  entry.durations.total // Total time it took to process this entry\n  entry.durations.read // Time it took to read the source file\n  entry.durations.cache // Time it took to read the cached content\n  entry.durations.generate // Time it took to generate the resulting file\n  entry.sizes.input // Size of the input file\n  entry.sizes.output // Size of the output file\n}\n```\n\n## Statistics\n\nUsing the above-mentioned Logging capabilities it is possible to generate\nstatistics about the project that you are rendering. These statistics can\ngive clarity about why builds are slow and if everything worked right.\n\n`browserify-persist-fs` comes with a small statistics module that can generate\na useful view:\n\n```javascript\nconst stats = require('browserify-persist-fs/stats')()\nconst browserifyPersistFs = require('browserify-persist-fs')('.cache', {}, stats.update)\n\n// ...\n// After processing and gc:\n\nbrowserifyPersistFs.gc({/*...*/, function (err, deletedFiles) {\n  console.log(stats.render(err, deletedFiles))\n})\n```\n\nwhich should show something like:\n\n```\nAvg. duration pre file for reading: 109.9ms\nAvg. duration per file for generating: 1ms\nFiles built: 0\nFiles with error: 0\nFiles cached: 1155\nGarbage collected files: 0\nSlowest files:\n- /Users/martinheidegger/project/client/js/app/components/draw/DrawObjectText.js (total: 257ms, reading: 105.96ms, generating: 1ms)\n- /Users/martinheidegger/project/client/js/app/components/draw/DrawObjectCanvas.js (total: 255.98ms, reading: 106.21ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/rgb2hex/index.js (total: 255.9ms, reading: 126.53ms, generating: 1ms)\n- /Users/martinheidegger/project/client/js/app/components/draw/DrawObjectPen.js (total: 255.73ms, reading: 106.07ms, generating: 1ms)\n- /Users/martinheidegger/project/client/js/app/components/draw/StampTool.js (total: 254.7ms, reading: 105.96ms, generating: 1ms)\n- /Users/martinheidegger/project/client/js/app/components/draw/ToolButtons.js (total: 254.68ms, reading: 106.23ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react-bootstrap/lib/utils/index.js (total: 252.14ms, reading: 129.16ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/jsondiffpatch/src/main.js (total: 247.01ms, reading: 130.37ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactPropTypeLocationNames.js (total: 244.29ms, reading: 101.02ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/checkReactTypeSpec.js (total: 244.31ms, reading: 99.56ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/canDefineProperty.js (total: 244.21ms, reading: 101.09ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/traverseAllChildren.js (total: 244.21ms, reading: 100.87ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactPropTypesSecret.js (total: 243.18ms, reading: 99.58ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/reactProdInvariant.js (total: 242.94ms, reading: 101.01ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/PooledClass.js (total: 243.1ms, reading: 100.84ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactComponentTreeHook.js (total: 243.02ms, reading: 99.56ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactNoopUpdateQueue.js (total: 242.93ms, reading: 99.58ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/getIteratorFn.js (total: 241.89ms, reading: 99.83ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactElementSymbol.js (total: 241.83ms, reading: 98.3ms, generating: 1ms)\n- /Users/martinheidegger/project/node_modules/react/lib/ReactCurrentOwner.js (total: 241.67ms, reading: 98.31ms, generating: 1ms)\n```\n\n## License\n\nMIT\n\n## Mentions\n\nI was able to work on this thanks to [Nota](https://notainc.com) that produces\n[Scrapbox](https://scrapbox.io) and [Gyazo](https://gyazo.com) since we\nneeded this to make our build run on speed!🏃‍\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Fbrowserify-persist-fs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinheidegger%2Fbrowserify-persist-fs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Fbrowserify-persist-fs/lists"}