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

@agebrock/total-typescript

v0.0.2

Published

esm commonjs typescript for the rest of us

Downloads

6

Readme

_ts - A TypeScript Runner for Node.js

Today with TypeScript and a sprinkle of ES module and CommonJS debugging! 🚀

We wanted this to have a simple TypeScript runner for Node.js, but it turned into a wild adventure. 😅

_ts script.ts

What's this all about?

So, picture this: you're setting up a new TypeScript generator for Node.js, just minding your own business. You're usually switching between Bun and Node, depending on the use case. But somehow, you end up in the deep, dark depths of ES module and CommonJS hell in Node.js. 😱

The Mission

Your goal? To run TypeScript smoothly like butter, using imports without file extensions. You want to import stuff like:

import { foo } from "./lib/foo"; // No need for foo.js!
import { someESModule } from "ems-module";
import { commonJSModule } from "common-js-module";

But wait, there's more! You also want the debugger to work out of the box, with minimal configuration. Easy peasy, right? Well, not quite.

(well maybe it is, but let's pretend it's not for the sake of this story) - but still if you know how to do it, please let me know! 😅

The Struggle is Real

You've tried everything - ts-node, ts-node-ems, tsx - but alas, nothing seems to work. It's like banging your head against a wall. 😩

So, you turn to Discord for help, only to find that everyone else is facing the same issues. Misery loves company, right?

The Hack of the Day

But fear not! After a nasty combination of PowerShell wizardry and a tiny hack of ts-node with a Node flag, you finally crack the code! 💥

Here's what you had to do:

  1. Run Node with --experimental-specifier-resolution=node.
  2. Run Node with a gnarly script injection:
--import 'data:text/javascript, import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL(process.env.TS_NODE_PATH));'

The Journey Continues...

Unfortunately, you weren't able to inject a tsconfig.json just yet. But fear not, dear reader! You believe it's possible, and when you find the solution, you'll be the first to know! 😎

In the meantime, you've concocted a clever hack in the configuration.js that gets injected into ts-node on post-installation. Who knew hacking could be so much fun?

And because you're a Linux and WSL lover, you've added Unix support as well! The ts2 command works like a charm, thanks to yet another hack you've never seen before. What a day, indeed! 🎩

But for now, rejoice! You can execute TypeScript just like in Bun with:

_ts script.ts

And that's the Daily.js project for you! Stay tuned for more adventures in the wild world of TypeScript and Node.js. 🌟