{"id":20192,"library":"loader-fs-cache","title":"loader-fs-cache","description":"A filesystem cache helper extracted from babel-loader's fs-cache module. Version 1.0.3 is the latest and only release. This package provides a simple promisified file system cache that stores compiled results on disk, checking timestamps and content hashes to invalidate stale entries. It is a standalone extraction from the babel-loader source. Not recommended for direct use; prefer babel-loader or other caching solutions like webpack's persistent cache.","status":"deprecated","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/viankakrisna/loader-fs-cache","tags":["javascript"],"install":[{"cmd":"npm install loader-fs-cache","lang":"bash","label":"npm"},{"cmd":"yarn add loader-fs-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add loader-fs-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Determines cache directory path based on package root","package":"find-cache-dir","optional":false},{"reason":"Recursively creates cache directories","package":"mkdirp","optional":false},{"reason":"Converts callback-based file operations to promises","package":"promisify-call","optional":false}],"imports":[{"note":"Package only provides a default export.","wrong":"const cache = require('loader-fs-cache');","symbol":"default","correct":"import cache from 'loader-fs-cache'"},{"note":"Named import does not exist; only default.","wrong":"import { cache } from 'loader-fs-cache';","symbol":"cache","correct":"import cache from 'loader-fs-cache'"},{"note":"No explicit type exports; use typeof.","wrong":"import type Cache from 'loader-fs-cache';","symbol":"type","correct":"type Cache = typeof import('loader-fs-cache')"}],"quickstart":{"code":"import cache from 'loader-fs-cache';\nimport findCacheDir from 'find-cache-dir';\nimport { join } from 'path';\n\nconst cacheDir = findCacheDir({ name: 'my-repo' }) ?? '.';\n\nconst src = 'const x = 1;';\nconst options = {\n  directory: cacheDir,\n  identifier: 'babel',\n  config: { presets: ['@babel/preset-env'] },\n};\n\ncache(options).then((result) => {\n  if (result && result.src === src) {\n    console.log('Cache hit');\n  } else {\n    console.log('Cache miss');\n  }\n});","lang":"typescript","description":"Demonstrates basic usage: import, find cache directory, set up cache options, and check for cache hit/miss."},"warnings":[{"fix":"Use babel-loader's built-in cache or implement your own caching with find-cache-dir and fs.","message":"This package is no longer maintained. It was extracted from babel-loader and has been superseded by babel-loader's own caching or other solutions.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure you include a hash of the source in the identifier or config to guarantee invalidation.","message":"The cache key is generated from `identifier` and `config` but not from source hash. If source changes without different identifier/config, old cache may be returned.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Provide a fallback directory when using `findCacheDir`.","message":"The package relies on `find-cache-dir` which may return `undefined` if no package root is found, causing errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install find-cache-dir","cause":"Missing peer dependency `find-cache-dir`.","error":"Cannot find module 'find-cache-dir'"},{"fix":"Use `import cache from 'loader-fs-cache'` instead of `import { cache } from 'loader-fs-cache'`.","cause":"Using named import instead of default import.","error":"TypeError: cache(...) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}