Skip to content

Extension to require TypeScript files from Node

License

Notifications You must be signed in to change notification settings

PopSugar/typescript-register

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Register NPM Version Build Status Coverage

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

Examples

foo.ts

export var foo = 3;

bar.js

require('typescript-register');
var foo = require('./foo');

console.log(foo.foo);

Installation

Install with npm:

npm install typescript-register

Configuration

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 errors
  • TYPESCRIPT_REGISTER_USE_CACHE: Whether or not to use previously emitted files
  • TYPESCRIPT_REGISTER_COMPILER_OPTIONS: The JSON stringified TypeScript compiler options

Contributing

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.

About

Extension to require TypeScript files from Node

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%