• Stars
    star
    3,403
  • Rank 13,143 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Compiles your TS app and restarts when files are modified.

ts-node-dev

Tweaked version of node-dev that uses ts-node under the hood.

It restarts target node process when any of required files changes (as standard node-dev) but shares Typescript compilation process between restarts. This significantly increases speed of restarting comparing to node-dev -r ts-node/register ..., nodemon -x ts-node ... variations because there is no need to instantiate ts-node compilation each time.

Install

npm (scoped) Build Status

yarn add ts-node-dev --dev
npm i ts-node-dev --save-dev

Usage

ts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [node cli flags] [--] [script] [script arguments]

So you just combine node-dev and ts-node options (see docs of those packages):

ts-node-dev --respawn --transpile-only server.ts

There is also short alias tsnd for running ts-node-dev:

tsnd --respawn server.ts

Look up flags and options can be used in ts-node's docs.

Also there are additional options specific to ts-node-dev:

  • --ignore-watch - (default: []) - files/folders to be ignored by node-dev. But this behaviour is enhanced: it also supports regular expression in the ignore strings and will check absolute paths of required files for match.

  • --deps - Also watch node_modules; by default watching is turned off

  • --debug - Some additional [DEBUG] output

  • --quiet - Silent [INFO] messages

  • --interval - Polling interval (ms) - DOESN'T WORK CURRENTLY

  • --debounce - Debounce file change events (ms, non-polling mode)

  • --clear (--cls) - Will clear screen on restart

  • --watch - Explicitly add arbitrary files or folders to watch and restart on change (list separated by commas, chokidar patterns)

  • --exit-child - Adds 'SIGTERM' exit handler in a child process.

  • --rs - Allow to restart with "rs" line entered in stdio, disabled by default.

  • --notify - to display desktop-notifications (Notifications are only displayed if node-notifier is installed).

  • --cache-directory - tmp dir which is used to keep the compiled sources (by default os tmp directory is used)

If you need to detect that you are running with ts-node-dev, check if process.env.TS_NODE_DEV is set.

Points of notice:

  • If you want desktop-notifications you should install node-notifier package and use --notify flag.

  • Especially for large code bases always consider running with --transpile-only flag which is normal for dev workflow and will speed up things greatly. Note, that ts-node-dev will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.

  • --ignore-watch will NOT affect files ignored by TS compilation. Use --ignore option (or TS_NODE_IGNORE env variable) to pass RegExp strings for filtering files that should not be compiled, by default /node_modules/ are ignored.

  • Unknown flags (node cli flags are considered to be so) are treated like string value flags by default. The right solution to avoid ambiguity is to separate script name from option flags with --, for example:

    ts-node-dev --inspect -- my-script.ts
    
  • The good thing is that ts-node-dev watches used tsconfig.json file, and will reinitialize compilation on its change, but you have to restart the process manually when you update used version of typescript or make any other changes that may effect compilation results.

Issues

If you have an issue, please create one. But, before:

  • try to check if there exits alike issues.
  • try to run your code with just ts-node
  • try to run your code with --files option enabled (see ts-node docs)
  • try to run it with --debug flag and see the output
  • try to make create repro example

Versioning

Currently versioning is not stable and it is still treated as pre-release. You might expect some options API changes. If you want to avoid unexpected problems it is recommended to fixate the installed version and update only in case of issues, you may consult CHANGELOG for updates.

License

MIT.

More Repositories

1

yalc

Work with yarn/npm packages locally like a boss.
TypeScript
5,531
star
2

my-nerd-fonts

97
star
3

mongoose-fill

Virtual async fileds for mongoose.js
JavaScript
60
star
4

cycle-hmr

๐Ÿ”ฅ Hot module replacement for Cycle.js.
JavaScript
30
star
5

yall

Yarn/npm for monorepos
TypeScript
27
star
6

cycle-async-driver

Factory for creating async request/response cycle.js drivers
JavaScript
23
star
7

vscode-autosave-ext

AutoSave Extension for VSCodee
TypeScript
16
star
8

babel-plugin-cycle-circular

Babel plugin allowing to have circular dependencies in cycle.js functions.
JavaScript
15
star
9

cycle-proxy

Circular proxy for Cycle.js.
TypeScript
13
star
10

lp-loader

Frictionless language packs for Webpack.
TypeScript
13
star
11

cycle-mongoose

Mongoose.js driver for Cycle.js.
JavaScript
11
star
12

cycle-express

Express.js driver for cycle.js
JavaScript
9
star
13

ts-clean-built

JavaScript
8
star
14

mocha-types

TypeScript definitions for mocha without globals
7
star
15

steal-hmr

Hot module replacement (reload) for StealJS/System.js
JavaScript
7
star
16

cycle-convert

๐ŸŒ— Convert cycle.js dataflows like a boss.
JavaScript
7
star
17

inspinia-admin

INSPINIA - Responsive Admin Theme, Static for StealJS, version 2.4
HTML
7
star
18

purs-node

Runs purescript output without hassle.
JavaScript
6
star
19

steal-lp

L(anguage) packs for StealJS applicaitons
JavaScript
5
star
20

rx-hot

๐Ÿ”ฅ Hot RxJS (v.4) streams
JavaScript
5
star
21

can-hot

Hot reloading for canjs components
JavaScript
5
star
22

watchalive

Serve, transform, and watch dev assets smartly.
JavaScript
4
star
23

steal-pack-bundles

JavaScript
3
star
24

cycler

TypeScript
3
star
25

cycle-sqs

Amazon SQS driver for Cycle.js
JavaScript
2
star
26

babel-plugin-cycle-hmr

Babel plugin for cycle.js hot module replacement (HMR).
JavaScript
2
star
27

material-dashboard-pro

JavaScript
2
star
28

grunt-steal-cache-bust

JavaScript
2
star
29

paper-dashboard

CSS
2
star
30

gruntfiles-mix

JavaScript
1
star
31

ts-remove-comment-import

JavaScript
1
star
32

vscode-ps-simple-format

TypeScript
1
star
33

mongodb-backup

TypeScript
1
star
34

vscode-taskmate

Launch terminal tasks like a boss.
TypeScript
1
star
35

readium.github.com

JavaScript
1
star
36

yrun

Run like a boss.
JavaScript
1
star
37

slog

JavaScript
1
star