@ts-tools/node

6.1.0 • Public • Published

@ts-tools/node

npm version

TypeScript support for Node.js.

This package installs a require extension, adding support for running .ts and .tsx files directly from source.

Features:

  • Fast! Uses ts.transpileModule. Leaves type checking to other flows.
  • Uses persistent disk caching (./node_modules/.cache/ts-<module>-<target>). Second run will not re-transpile a file if not changed.
  • Built-in support for source-maps, powered by source-map-support.
  • Node 8+ friendly default compiler options.

Getting started

Install the library as a dev dependency in an existing TypeScript project:

npm i @ts-tools/node --save-dev

Usage with Node.js:

node -r @ts-tools/node/r ./my-script.ts

Usage with Mocha:

mocha -r @ts-tools/node/r "./test/**/*.test.ts?(x)" --watch-extensions ts,tsx

OR, create a .mocharc.js file with:

module.exports = {
  require: ['@ts-tools/node/r'],
  extension: ['js', 'json', 'ts', 'tsx'],
};

Usage with Visual Studio Code:

// in .vscode/launch.json, under "configurations"
{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "runtimeArgs": ["-r", "@ts-tools/node/r"],
  "args": ["${workspaceFolder}/src/my-script.ts"],
}

Similar projects

ts-node - a much more complete solution. It includes a ts-node cli/repl, and require hook registration.

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
6.1.0118latest

Version History

VersionDownloads (Last 7 Days)Published
6.1.0118
6.0.0304
5.0.2416
5.0.11
5.0.00
4.0.0395
3.0.1125
2.1.1129
2.1.00
2.0.05
1.1.341
1.1.28
1.1.10
1.1.00
1.0.01
0.11.03
0.9.100
0.9.90
0.9.80
0.9.71
0.9.60
0.9.50
0.9.41
0.9.30
0.9.20
0.9.10
0.9.00
0.8.30
0.8.20
0.8.10
0.8.01
0.7.43
0.7.30
0.7.20
0.7.10
0.7.00
0.6.81
0.6.70
0.6.60
0.6.50
0.6.40
0.6.30
0.6.20
0.6.10

Package Sidebar

Install

npm i @ts-tools/node

Weekly Downloads

1,400

Version

6.1.0

License

MIT

Unpacked Size

23.1 kB

Total Files

18

Last publish

Collaborators

  • avi.vahl