Package Exports
- ts-node-dev
- ts-node-dev/bin/ts-node-dev
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-node-dev) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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
yarn add ts-node-dev --devnpm i ts-node-dev --save-devts-node dependency version is not fixed, so it will install the latest version by default.
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.tsThere is also short alias tsnd for running ts-node-dev:
tsnd --respawn server.tsLook 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 bynode-dev. But also this behaviour enhanced: it will also make upnew RegExpof passed ignore string and check absolute paths of required files for match.use
--depsto watchnode_modules, by default watching it turned off.
--debug- Some additional debug output.--interval- Polling interval (ms)--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.--no-notify- Do not display desktop-notifications (Notifications are only displayed ifnode-notifieris installed).
If you need to detect that you are running with ts-node-dev, check if process.env.TS_NODE_DEV is set.
Desktop Notifications
If you want desktop-notifications you should install node-notifier package.
Caveats and points of notice:
Especially for large code bases always consider running with
--transpile-onlyflag which is normal for dev workflow and will speed up things greatly. Note, thatts-node-devwill not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.--ignore-watchwill NOT affect files ignored by TS compilation. Use--ignoreoption (orTS_NODE_IGNOREenv variable) to pass RegExp strings for filtering files that should not be compiled, by default/node_modules/are ignored.Unknown flags (
nodecli 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.tsThe good thing is that
ts-node-devwatches usedtsconfig.jsonfile, and will reinitialize compilation on its change, but you have to restart the process manually when you update used version oftypescriptor make any other changes that may effect compilation results.
License
WTF.