$ cnpm install require-precompiled
Require extension that allows for caching/precompiling
$ npm install --save require-precompiled
const installPrecompiler = require('require-precompiled');
const cache = require('my-cache-implementation');
installPrecompiler(filename => {
if (cache.hasEntryFor(filename)) {
return cache.getPrecompiledCode(filename);
}
// fall through to underlying extension chain;
return null;
});
// Any module required from this point on will be checked against the cache.
const foo = require('some-module');
Type: Function(string: filename)
Return string contents for a cache hit, or null for a miss.
MIT © James Talmage
Copyright 2013 - present © cnpmjs.org | Home |