Socket
Socket
Sign inDemoInstall

@ava/require-precompiled

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ava/require-precompiled

Require extension that allows for caching/precompiling


Version published
Weekly downloads
6.7K
decreased by-23.69%
Maintainers
3
Weekly downloads
 
Created
Source

require-precompiled

Modifies require() so you can load precompiled module sources.

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

function installPrecompiler(
	loadSource: (filename: string) => string | null,
	ext = '.js',
): void

The 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

Keywords

FAQs

Package last updated on 09 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc