Package Exports
- @ava/require-precompiled
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ava/require-precompiled) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
require-precompiled
Modifies require() so you can load precompiled module sources.
Install
$ npm install --save require-precompiledUsage
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
function installPrecompiler(
loadSource: (filename: string) => string | null,
ext = '.js',
): voidThe loadSource() function should return a source string when a precompiled source is available. Return null to fall back to Node.js' default behavior.
By default the precompiler is installed for .js files. You can specify alternative extensions by providing the second argument:
installPrecompiler(filename => {
// ...
}, '.cjs')License
MIT © James Talmage