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

http-modules

v0.0.1

Published

Import HTTPS modules in Bun and Node.js.

Readme

http-modules

http-modules lets JavaScript runtimes import modules directly from https:// URLs.

The package currently supports:

  • Bun, through a preloadable Bun.plugin.
  • Node.js, through module customization hooks.
  • Remote JavaScript and TypeScript modules.
  • Relative imports inside fetched remote modules.

Why this exists

Browsers and Deno can import URL-based modules as first-class module specifiers. Bun and Node.js normally expect package, file, or built-in specifiers. This package fills that gap for runtime code that wants to write normal static imports against HTTPS module URLs:

import { nanoid } from "https://cdn.jsdelivr.net/npm/[email protected]/index.browser.js";

Install

bun add http-modules

Bun

Preload the Bun plugin before any static HTTPS imports are resolved:

# bunfig.toml
preload = ["http-modules/bun"]

Then import HTTPS modules directly:

import { nanoid } from "https://cdn.jsdelivr.net/npm/[email protected]/index.browser.js";

console.log(nanoid());

For local development in this repo, bunfig.toml preloads ./src/bun.ts so the source plugin is exercised directly.

Node.js

Preload the Node registration entrypoint:

node --import http-modules/node/register ./app.mjs

Then import HTTPS modules directly:

import { basename } from "https://deno.land/[email protected]/path/mod.ts";

console.log(basename("/tmp/example.ts"));

Node.js support uses asynchronous module customization hooks. Remote TypeScript modules require Node.js >=22.6, because Node must understand the module-typescript loader format.

If you need to register hooks yourself, use:

import { register } from "node:module";

register("http-modules/node/hooks", import.meta.url);

Package entrypoints

| Export | Purpose | | --- | --- | | http-modules | Shared helper exports. No runtime side effects. | | http-modules/bun | Registers the Bun HTTPS import plugin. Use as a Bun preload. | | http-modules/node/register | Registers Node customization hooks. Use with node --import. | | http-modules/node/hooks | Raw Node hook module for manual registration. |

Behavior

  • Only https:// module specifiers are handled.
  • HTTP errors fail module loading with the response status.
  • Remote JavaScript and TypeScript sources have relative import specifiers rewritten to absolute HTTPS URLs before evaluation. This keeps nested remote imports working across both runtimes.
  • JSON modules are loaded as JSON where the runtime supports that loader format.
  • No cache is implemented yet. Every process fetches remote modules through the runtime loader path.

Development

This repo uses Bun for package management and build tasks, with mise pinning Bun and Node versions.

mise install
bun install
bun run build
bun run test
bun run typecheck

Equivalent mise tasks:

mise run build
mise run test
mise run typecheck

bun run test builds dist/ and then runs the cross-runtime test suite. The tests start a local HTTPS server with fixture modules, then verify both Bun and Node can import the same remote module graph without depending on third-party networks.

Repository layout

src/shared.ts         Shared fetch, format detection, and import-rewrite logic.
src/bun.ts            Bun plugin entrypoint.
src/node/hooks.ts     Node async resolve/load hooks.
src/node/register.ts  Node --import registration entrypoint.
src/index.ts          Side-effect-free public helper exports.

Build output is written to dist/ and included in the published package.