Extension to require TypeScript files from Node. This project is an alternative to typescript-require. The main differences are:
- Dependencies are run in the same context as the parent
- Uses the TypeScript API as opposed to forking
tsc
- Caches dependencies in
/tmp/typescript-register/:your/:path/:here
export var foo = 3;
require('typescript-register');
var foo = require('./foo');
console.log(foo.foo);
Install with npm:
npm install typescript-register
There are three configuration options which are read from environment variables. The configuration options are read each time a module is required so you can programatically set them with:
process.env[':name'] = ':value';
The values are:
TYPESCRIPT_REGISTER_EMIT_ERROR
: Whether or not emit fatal TypeScript errorsTYPESCRIPT_REGISTER_USE_CACHE
: Whether or not to use previously emitted filesTYPESCRIPT_REGISTER_COMPILER_OPTIONS
: The JSON stringified TypeScript compiler options
Feel free to fork and submit pull requests for the code! Please follow the existing code as an example of style and make sure that all your code passes tests.