{"_id":"@ava/require-precompiled","_rev":"198428","name":"@ava/require-precompiled","description":"Require extension that allows for caching/precompiling","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"novemberborn","email":"mark@novemberborn.net"}],"time":{"modified":"2021-06-03T12:30:17.000Z","created":"2020-02-09T13:54:05.860Z","1.0.0":"2020-02-09T13:54:05.860Z"},"users":{},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"repository":{"type":"git","url":"git+https://github.com/avajs/require-precompiled.git"},"versions":{"1.0.0":{"name":"@ava/require-precompiled","version":"1.0.0","description":"Require extension that allows for caching/precompiling","license":"MIT","repository":{"type":"git","url":"git+https://github.com/avajs/require-precompiled.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=10"},"scripts":{"test":"xo && nyc ava"},"keywords":["require","extension","cache","precompile"],"devDependencies":{"ava":"^3.2.0","fake-module-system":"^0.3.0","nyc":"^15.0.0","xo":"^0.25.3"},"nyc":{"reporter":["html","lcov","text"]},"gitHead":"73ffbe6a413524d6f86f6fe0ddc8dfb29dc2ae7d","bugs":{"url":"https://github.com/avajs/require-precompiled/issues"},"homepage":"https://github.com/avajs/require-precompiled#readme","_id":"@ava/require-precompiled@1.0.0","_nodeVersion":"12.14.1","_npmVersion":"6.13.6","dist":{"shasum":"6f4a48b75904a753eadff020bbfca81d3bbc0357","size":1965,"noattachment":false,"key":"/@ava/require-precompiled/-/@ava/require-precompiled-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@ava/require-precompiled/download/@ava/require-precompiled-1.0.0.tgz"},"maintainers":[{"name":"novemberborn","email":"mark@novemberborn.net"}],"_npmUser":{"name":"novemberborn","email":"mark@novemberborn.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/require-precompiled_1.0.0_1581256445729_0.22046781184064046"},"_hasShrinkwrap":false,"publish_time":1581256445860,"_cnpm_publish_time":1581256445860}},"readme":"# require-precompiled\n\nModifies `require()` so you can load precompiled module sources.\n\n## Install\n\n```\n$ npm install --save require-precompiled\n```\n\n## Usage\n\n```js\nconst installPrecompiler = require('require-precompiled');\nconst cache = require('my-cache-implementation');\n\ninstallPrecompiler(filename => {\n\tif (cache.hasEntryFor(filename)) {\n\t\treturn cache.getPrecompiledCode(filename);\n\t}\n\t// fall through to underlying extension chain\n\treturn null;\n});\n\n// any module required from this point on will be checked against the cache\nconst foo = require('some-module');\n```\n\n## API\n\n```ts\nfunction installPrecompiler(\n\tloadSource: (filename: string) => string | null,\n\text = '.js',\n): void\n```\n\nThe `loadSource()` function should return a source string when a precompiled source is available. Return `null` to fall back to Node.js' default behavior.\n\nBy default the precompiler is installed for `.js` files. You can specify alternative extensions by providing the second argument:\n\n```js\ninstallPrecompiler(filename => {\n\t// ...\n}, '.cjs')\n```\n\n## License\n\nMIT © [James Talmage](https://github.com/jamestalmage)\n","_attachments":{},"homepage":"https://github.com/avajs/require-precompiled#readme","bugs":{"url":"https://github.com/avajs/require-precompiled/issues"},"license":"MIT"}