require-precompiled

Require extension that allows for caching/precompiling

MIT 1 个版本
安装
npm install require-precompiled
yarn add require-precompiled
pnpm add require-precompiled
bun add require-precompiled
README

require-precompiled Build Status Coverage Status

Require extension that allows for caching/precompiling

Install

$ npm install --save require-precompiled

Usage

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');

API

requirePrecompiled(callback)

callback

Type: Function(string: filename)

Return string contents for a cache hit, or null for a miss.

License

MIT © James Talmage

版本列表
0.1.0 2015-12-16