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

snohmr

v2.2.1

Published

🔥 Hot Module Replacement for Node.{js,mjs,ts} in ESM

Downloads

5

Readme

SNOHMR-2

🔥 Hot Module Replacement for Node.{js,mjs,ts} in ESM

  • TypeScript support
  • Watch latest changes
  • Native ESModule support (compared to node-hmr)
  • Boost your Node.TS development with just ONE line of for-await-of

Install

npm i -D snohmr
pnpm i -D snohmr

Examples

🔥 HMR in same file ♾

Running a module from an cli or somewhere else, and the file need to be debugging is ....

// /src/demo/self.ts
import snohmr from "../index";

export default async function main() {
  await new Promise(() => setTimeout(r, 1000)); // so heavy data loader
  const str = '["JSON"]';
  // SNOHMR magic incantation applied!
  for await (const module of snohmr(() => import("./self"))) {
    // const module is always latest version
    const { myparse } = module;
    // print latest myparse result immediately while you change this file,
    console.log({ parsedObject: myparse(str) });
    // = { parsedObject: ["JSON"] }
  }
}
export function myparse(input: string) {
  console.log({ input });
  return JSON.parse(input);
}
export function mystringify(input: any) {
  console.log({ input });
  return JSON.stringify(input);
}

🔥 HMR parse.ts from an loader 🔬

The file needs to be HMR debugging

// /parse.ts
export default function parse(data: string) {
  console.log(data);
  return JSON.parse(data);
}

And the data loader is calling parse.ts by snohmr.

// /cli.ts
import snohmr from "snohmr";

// load data
const data = await load(); // heavy function

// if this is your original way to call parse function from dynamic import
{
  const { default: parse } = await import("./parse");
  await parse(data).then(console.log);
}
// and then simpliy replace it with below then enjoy parse with SNOHMR
{
  for await (const { default: parse } of snohmr(() => import("./parse")))
    await parse(data).then(console.log).catch(console.error);
}

Reference

About

License

GPLv3 - The GNU General Public License v3.0 - GNU Project - Free Software Foundation

Author

Author: snomiao [email protected] Website: snomiao.com

Sponsors

  • None yet.

Claim your sponsorship by donating snomiao <Email: [email protected]>

Contribute

The main repo is in here, any issue and PR's welcome.