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

esyes

v1.0.3

Published

Run your TypeScript files quickly and with more positivity.

Downloads

1,114

Readme

esyes

standard-readme compliant

Run your TypeScript files quickly and with more positivity.

esyes transforms your JavaScript and TypeScript files using esbuild-kit. It works seamlessly and requires no configuration to get the job done.

It also translates import.meta.env features on the fly, so you can use JavaScript or TypeScript modules written with import.meta.env directly in Node.

Hat tip to @NullVoxPopuli for the idea, originally implemented in this PR in the Starbeam repository.

Table of Contents

Install

When using esyes to run npm scripts, install via your package manager.

$ pnpm i -D esyes

You can also install esyes globally via your package manager.

$ pnpm i -g esyes

You can also install esyes with volta, which allows you to bind it to a node version.

$ volta install esyes node@20

If you install esyes via volta and you're using it in a project with a pinned version of Node in its package.json, esyes will automatically use that version.

Usage: Instead of the node Command

$ cat hi.ts
const hello = "hello" as const;
console.log(hello);

$ esyes hi.ts
hello

All node flags and environment variables are passed through to node, so it's a true drop-in replacement for the node command.

There's one divergence: node without any arguments will run the Node REPL, while esyes with no arguments prints usage information.

Usage: As a Loader

You can use esyes directly as a Node loader without any experimental warnings.

$ cat hi.ts
const hello = "hello" as const;
console.log(hello);

$ node --import esyes hi.ts
hello

esyes uses Node's new module.register API. This is the API that the warnings you might have seen advise you to use.

import.meta.env Support

esyes will automatically transform many of the import.meta.env features supported by Vite so that you can use them directly in your JavaScript or TypeScript code.

$ cat hi.ts
const hello = "hello" as const;

if (import.meta.env.DEV) {
  console.log(hello);
} else {
  console.log("not in dev mode!");
}

$ node --import esyes hi.ts
hello

$ MODE=prod node --import esyes hi.ts
not in dev mode

This transform applies to all files, including files in your node_modules, which makes using import.meta.env transparent, even if some of the code you're working on is in node_modules (such as when working in monorepos).

The transform is expected to be extremely fast when no import.meta.env is used (it just does a quick check for import.meta.env before doing any other work).

Advanced: Internals Tracing

If the loader isn't doing what you expect, you can enable trace logging to see all of the files that the loader is processing, and the processing steps it's taking.

$ cat hi.ts
const hello = "hello" as const;

if (import.meta.env.DEV) {
  console.log(hello);
} else {
  console.log("not in dev mode!");
}

$ EYES_LOADER_LOG=log.txt node --import esyes hi.ts
hello

$ cat log.txt
load: "file:///.../hi.ts"
search for "import.meta.env" (from 0):
  found at: 23
lookahead for ".":
  found: "38..39"
lookahead for /^(MODE|DEV|PROD|TRACE)/:
  found: "39..42"
replacing:
  range: "23..42"
  with: "true"
search for "import.meta.env": "not found"

Maintainers

The Starbeam team.

Contributing

See the contributing file!

License

MIT © 2023 Yehuda Katz