Registry / devops / file-transform-cache

file-transform-cache

JSON →
library2.0.0jsnpmunverified

A build-system independent API for applying transformations to files and caching the results in a persistent cache. Version 2.0.0 (stable) uses vinyl files and supports caching based on file hash or modification time. Alternatives like Gulp or Webpack are full build systems; this is a lightweight library focused solely on transform caching.

npm install file-transform-cache
INSTALL
IMPORT
SIG · FILE-TRANSFORM-CAC
F
file-transform-cache
devopsjavascriptv2.0.0
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 (ftcache)
import ftcache from 'file-transform-cache';
const ftcache = require('file-transform-cache');
ESM default import; CJS require also works
ftcache
const ftcache = require('file-transform-cache');
import { ftcache } from 'file-transform-cache';
Named import does not exist; use default import
TypeScript types
import ftcache from 'file-transform-cache';
No built-in TypeScript types; use @types/file-transform-cache if available

Creates a cache with a transform pipeline, transforms a single file, and saves the cache.

import ftcache from 'file-transform-cache'; const transform1 = (opts) => { return (file, next) => { // Example transform: append a string to file contents file.contents = Buffer.concat([file.contents, Buffer.from(' transformed1')]); next(null, file); }; }; const ftc = ftcache({ path: '.myCache', transforms: [transform1({})] }); ftc.transform('example.js', (err, file) => { if (err) { console.error('Error:', err); return; } console.log('Result:', file.contents.toString()); ftc.save(); });
Debug
Known issues
gotchaCache file is not automatically saved; you must call ftc.save() to persist.
fix
Call ftc.save() after all transformations are done.
affects: >=2.0.0
gotchaTransform functions must call the callback next(null, file) or pass an error. Forgetting to call next will hang the process.
fix
Ensure each transform function invokes next(null, file) after processing.
affects: >=2.0.0
gotchaThe 'path' option is required; if omitted, the module will throw.
fix
Set options.path to a valid file path for the cache.
affects: >=2.0.0
deprecatedThe 'hash' option may be deprecated in future versions; prefer using content hash via the 'hash' flag.
fix
Use options.hash: true to enable content-based caching.
affects: >=2.0.0
gotchatransformGlob results contain objects with 'file' and possibly 'err'; do not assume all are valid.
fix
Check for result.err before accessing result.file.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cache file path must be a string
The 'path' option is missing or not a string.
fix
Provide a valid string path to the cache file in the options object.
Callback 'next' is not a function
The transform function does not receive the callback correctly.
fix
Ensure the transform function signature is (file, next) and that next is called.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
vinylrequiredCore dependency for file representation in transformations
Agent activity
2 hits · last 30 days
node
2
Resources
file-transform-cache — npm install file-transform-cache · libregistry