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

hrts

v0.2.0

Published

A dumb TypeScript loader for modern Node.js

Downloads

3

Readme

hrts

A dumb TypeScript loader for modern Node.js

# Node.js >=20.6.0
# TypeScript >=5.5.0
npm i hrts
node --import hrts ./app.ts

why

  • hrts uses the locally installed typescript module and works like tsc. it type checks (unless you tell it not to).
  • hrts does not try to be smart. it does what you would expect it to do and nothing more. it's ~300 lines of code with no dependencies.
  • hrts targets modern Node.js. it uses the node:module customization hooks API to support both ESM and CommonJS and doesn't monkey patch anything.
  • the name is pretty good.

how

type checked

node --import hrts ./app.ts

not type checked

node --import hrts/nocheck ./app.ts

custom options

import register from "hrts/register.js"
register({
	check: process.env.NODE_ENV !== "production",
	defaults: "./tsconfig.defaults.json",
})

await import("./app.ts")

recommendations

  • set "type": "module" in your package.json. there are no reasons not to in a modern Node.js application.
  • set "module": "Node16" or "module": "NodeNext" in your tsconfig.json. other values are not suitable for modern Node.js.
  • set the --enable-source-maps flag when running your application to get accurate stack traces.
  • don't use hrts (or any other TypeScript loader for that matter) if performance is a concern.

config resolution

hrts looks for a tsconfig.json file in the same directory as the file being imported, then in every parent directory, until it finds one that is valid for the file.

If none is found, it falls back the provided default file. If no default is provided or if the default file is invalid, it falls back to a set of default options suitable for modern Node.js.

{
	"module": "Node16",
	"target": "ES2023",
	"strict": true,
	"allowImportingTsExtensions": true
}

The file is then compiled with that exact config (with the bare minimum patches to function as a loader). No effort is made to be smart about it and go from ESM to CommonJS or vice versa. What you get is what you get.