npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@floydophone/ts-node-dev

v1.0.0-pre.40

Published

Compiles your TS app and restarts when files are modified.

Downloads

7

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 --dev
npm i ts-node-dev --save-dev

ts-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 --transpileOnly server.ts

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

tsnd --respawn server.ts

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

  • --prefer-ts (default: false) - for each .js file (that is not in node_modules) will try to check if corresponding .ts version exists and require it.

  • --ignore-watch (default: []) - files/folders to be ignored by node-dev. But also this behaviour enhanced: it will also make up new RegExp of passed ignore string and check absolute paths of required files for match. So, to ignore everything in node_modules, just pass --ignore-watch node_modules.

  • --debug - some additional debug output.

  • --interval Polling interval (ms)

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

Caveats and points of notice:

  • 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.

  • In some rare cases ts-node-dev may fail to terminate an application by sending SIGTERM signal, this maybe be caused by the app having running heavy child process or something. But the app should get the signal anyway and it can be explicitly processed there: process.on('SIGTERM', () => process.exit()).

License

WTF.