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

live-tsc

v1.6.2

Published

A lightweight esbuild-based implementation of tsc that trim off the types (without type checking)

Downloads

17

Readme

live-tsc

A lightweight esbuild-based implementation of tsc that trim off the types (without type checking)

Intended to be used by ts-liveview but it should be generic enough as an alternative to "tsc --watch"

npm Package Version

Installation

npm i -D live-tsc

Command Line Usage

Usage Example:

npx live-tsc \
  --watch \
  --src     ./ \
  --dest    ./dist \
  --exclude ./scripts \
  --exclude ./public \
  --exclude ./data \
  --exclude ./db/data \
  --post-hook "npx fix-esm-import-path dist/db/proxy.js" \
  --server  ./dist/server/index.js \
  --open "https://localhost:8100"

Options:

  --src <dir|file>
    Specify the source directory/file
    Alias: -s

  --dest <dir|file>
    Specify the destination directory/file
    Alias: -d

  --exclude <dir|file>
    Specify the path to be excluded;
    Can be specified multiple times;
    The destination directory is excluded by default
    Alias: -e

  --project <file>
    Specify the path of tsconfig file
    Alias: -p
    Default: tsconfig.json

  --watch
    Watch for changes and rerun
    Alias: -w

  --format <cjs|esm|iife>
    Sets the output format for the generated JavaScript files
    Alias: -f
    Default: esm

  --post-hook <command>[#watch:<file1[,file2]>]
    Add command to run after initial scan and subsequence updates;
    If the watch files are specified, the hook will be re-run only if the specified files are changed,
    otherwise the hook will observe the source files;
    Can be specified multiple times;

  --post-script <npm script>[#watch:<file1[,file2]>]
    Add npm script to run after initial scan and subsequence updates;
    This is a shortcut as: --post-hook "npm run <script>";
    Details refers to "--post-hook"

  --server <file>
    Specify the path of server js file

  --cwd <dir>
    Specify the current working directory for the server and postHooks
    Alias: -c
    Default: sample as process.cwd

  --open <url>
    Open the url in the default browser after initial scanning
    Alias: -o

  --help
    Show help message
    Alias: -h

Why skip type checking?

This tool is intended to be used by the development server (potentially behind nodemon)

Running tsc on slow machine can takes some time.

Developers can get type checking error messages from the editor in realtime, so skipping type check on the build-flow should speed up iteration cycle without compromise.

It is a waste to do type checking twice in the cli build watcher and editor's language server.

Speed Comparison

Tested with ts-liveview v5

Environments

Env [1]:

  • archlinux Desktop
  • btrfs on HDD

Env [2]:

  • Mac mini (2014)
  • 2.6 GHz Dual-Core Intel i5
  • Macintosh HD (1TB SATA Disk)

Env [3]:

  • Kudu3 laptop
  • archlinux
  • 6th Gen 2.6 GHz 4 Core Intel i7
  • zfs on top of lvm

Run Type

Fresh Build: Removed the outDir before run

Incremental Build: Keep the outDir from previous run

Comparison

| Env | Tool | Fresh Build | Incremental Build | Improvement | | --- | -------- | ----------- | ----------------- | ----------- | | [1] | tsc | ? | 4.3s | ? | | [1] | live-tsc | ? | 0.1s | ? | | [2] | tsc | 11.2s | 2.8s | 4x | | [2] | live-tsc | 0.36s | 0.22s | 1.6x | | [3] | tsc | 3.2s | 1.9s | 1.6x | | [3] | live-tsc | 0.152s | 0.148s | 1.02 |

| Env | Fresh bulid Speedup Rate | Incremtntal Build Speedup Rate | | --- | ------------------------ | ------------------------------ | | [2] | 31x | 12x | | [3] | 21x | 12x |

The time used is the average of multiple runs. In practice, the cold-start run time of fresh build is much longer if the Typescript files are not already cached by the OS.

You can run the speed test on your machine by running npx ts-node src/test/measure-speed.ts

Todo

The watch mode seems not working on mac mini, maybe use polling as fallback.

License

This project is licensed with BSD-2-Clause

This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:

  • The freedom to run the program as you wish, for any purpose
  • The freedom to study how the program works, and change it so it does your computing as you wish
  • The freedom to redistribute copies so you can help others
  • The freedom to distribute copies of your modified versions to others