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 🙏

© 2026 – Pkg Stats / Ryan Hefner

esbuild-html-link

v1.1.0

Published

Replace links in html based on esbuild metafile

Readme

esbuild-html-link

Post processing for esbuild output to change copied html entry files to have <script src> and <link href> attributes that reference an entrypoint (like index.ts) to point to the output file instead, so <script src="index.ts"> to <script src="index.js">, and <link href="index.ts"> to <link href="index.css">.

The ideal supported command is this:

esbuild src/index.* --bundle --outdir=dist --metafile=meta.json --loader:.html=copy && esbuild-html-link

Future features

rename hashed html file

esbuild has an --entry-names options that you can add a hash in. This makes sense for JS/CSS, but not for html entries, since you need to know the name of the html file.

I'm going to make this a default, and just replace the base name with the base name of the source.

handle meta.json location

esbuild's --metafile option specifies where the metafile goes relative to your working directory, which is annoying since you probably don't have that in your .gitignore. However, to determine the src/output, I need to know your working directory and your metafile. If I wanted everything in dist, I'd have to do:

esbuild ... --metafile=dist/meta.json && esbuild-html-link -m dist/meta.json

Since it doesn't really make sense for me to assume your output is in dist, I can only default the name (defaults to meta.json).

A solution to this annoying thing is to either:

  • specify metafile directory
  • delete the meta.json on run
  • other?

specify metafile directory

esbuild ... --outdir=dist --metafile=dist/meta.json && esbuild-html-link -m dist

Uses the same flag for "metafile", but since it resolves to a directory we'll just add "meta.json" to it. This seems like an easy change to deal with this issue.

delete meta.json on run

esbuild ... --outdir=dist --metafile=meta.json && esbuild-html-link

This is nice because you don't need to repeat "dist" twice, or give me any extra info. It's weird because you're deleting a file that, if something fails, may not get deleted.

Potential future features

Not sure about these, but they're ideas.

watch mode

this seems silly because you'd still need separate processes, but it's probably easier to set up with concurrently or something than watchexec meta.json -- esbuild-html-link

non-entry html files

This could be useful if people like flows where they do import './index.html' from an index.ts file, but it seems weird. The main advantage I can think of is if you have a hash in your entry file and want an index.html (no hash) output, but there's a different feature for that.

RE: esbuild min version

The metafile produced by esbuild doesn't mark an html file as an entrypoint until 0.24.1.