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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@masx200/vite-plugin-virtual-http-resolve

v1.0.1

Published

A Vite plugin that resolves remote HTTP/HTTPS modules to virtual modules with caching support

Downloads

63

Readme

@masx200/vite-plugin-virtual-http-resolve

A Vite plugin that resolves remote HTTP/HTTPS modules to virtual modules with caching support.

Features

  • 🚀 Resolves remote HTTP/HTTPS modules as virtual modules
  • 📦 Built-in caching (memory and file system)
  • 🔧 Customizable fetcher function
  • 🎯 Handles relative imports from remote modules
  • 🛡️ Variable conflict resolution for node modules
  • ⚡ Fast and efficient with pre-processing

Installation

npm install @masx200/vite-plugin-virtual-http-resolve
# or
yarn add @masx200/vite-plugin-virtual-http-resolve
# or
pnpm add @masx200/vite-plugin-virtual-http-resolve

Usage

Basic Usage

// vite.config.js
import { defineConfig } from "vite";
import virtualHttpResolve from "@masx200/vite-plugin-virtual-http-resolve";

export default defineConfig({
  plugins: [virtualHttpResolve()],
});

With Custom Options

// vite.config.js
import { defineConfig } from "vite";
import virtualHttpResolve, {
  FileCache,
} from "@masx200/vite-plugin-virtual-http-resolve";

export default defineConfig({
  plugins: [
    virtualHttpResolve({
      // Use file cache instead of memory cache
      cache: new FileCache("./custom-cache-folder"),

      // Custom fetcher function
      fetcher: async (url) => {
        const response = await fetch(url);
        if (response.ok) return await response.text();

        throw Error("failed to fetch:" + url);
      },
    }),
  ],
});

In Your Code

// Import from remote HTTP/HTTPS URL
import React from "virtual:https://esm.sh/[email protected]";
import ReactDOM from "virtual:https://esm.sh/[email protected]";

// The plugin will automatically handle relative imports
// from these remote modules

API

virtualHttpResolve(options?)

Options

  • cache (CacheType) - Cache implementation for storing fetched modules. Defaults to in-memory cache.
  • fetcher (url: string) => Promise<string> - Custom fetcher function for HTTP requests.

CacheType Interface

interface CacheType {
  has(key: string): Promise<boolean> | boolean;
  set(key: string, value: string): Promise<any> | any;
  get(key: string): Promise<string | undefined> | string | undefined;
}

FileCache

A file system-based cache implementation.

const cache = new FileCache(cacheFolder?: string)

How It Works

  1. Virtual Module Resolution: Converts HTTP/HTTPS URLs to virtual modules (virtual:https://...)
  2. Relative Import Handling: Resolves relative imports from remote modules
  3. Caching: Stores fetched modules to avoid repeated requests
  4. Variable Conflict Resolution: Automatically resolves variable name conflicts in node modules
  5. Pre-processing: Handles special cases like chunk files and Skypack-style redirects

License

MIT