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

esm-hmr

v0.1.0

Published

a Hot Module Replacement (HMR) API for your ESM-based dev server.

Downloads

3

Readme

ESM Hot Module Replacement (ESM-HMR) Spec

Author: Fred K. Schott (co-authors welcome!)
Status: In Progress

Hot Module Replacement (HMR) lets your browser live-update individual JavaScript modules in your application during development without triggering a full browser reload or losing the current web application state. This speeds up your development speed with faster updates on every change.

Web bundlers like Webpack, Rollup, and Parcel all implemented different, bundler-specific HMR interfaces. This makes it hard to share HMR integrations across dev environments. As a result, many framework integrations like React Fast Refresh and Preact's Prefresh need to be rewritten for every bundler that they'd like to support. See:

  • https://github.com/facebook/react/issues/16604#issuecomment-528663101
  • https://github.com/JoviDeCroock/prefresh

ESM-HMR is a standard HMR API for ESM-based dev environments. The rise of bundle-free development creates the opportunity for a common, standard HMR API built on top of the browser's native module system. ESM-HMR is built for the browser's native module system, so it can be used in any ESM-based dev environment.

Who's Using ESM-HMR?

What's in This Repo?

  1. esm-hmr/client.js - A client-side ESM-HMR runtime.
  2. esm-hmr/server.js - A server-side ESM-HMR engine to manage connected clients.
  3. An ESM-HMR spec to help your write your own client/server pieces. (coming soon)

Example

// Automatically injected by the dev server:
import * as $HMR$ from '/esm-hmr/client.js';
import.meta.hot = $HMR$.createHotContext(import.meta.url);

// Your module's JavaScript code:
export let foo = 1;

// HMR Logic:
if (import.meta.hot) {
  // Required: Mark this module as HMR-ready.
  // - Receive any module updates into the accept callback.
  // - Update the main module acordingly.
  import.meta.hot.accept(({module}) => {
    try {
      foo = module.foo;
    } catch (err) {
      // Optional: If an error occurs during update, invalidate the module.
      // This will naively trigger a full page reload.
      import.meta.hot.invalidate();
    }
  });
  // Optional: Perform any cleanup when a module is replaced.
  import.meta.hot.dispose(() => { /* ... */ });
}

Spec Details

Note: We are still fleshing this out, and this section is still under development.

Our first goal is to generalize and document Snowpack's browser-native HMR implementation for a first-round of feedback. Our second goal is to expand this spec to support Preact's Prefresh, React's Fast Reload + Error Reporting, and any features needed by other popular HMR implementations.

Prior Art

This spec wouldn't exist without the prior work of the following projects: