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

ws-reload-plugin

v2.0.0

Published

an auto reload webpack plugin for chrome extension developers

Readme

这是一个 webpack 打包工具的 plugin,只有浏览器插件开发者用得到,功能类似 webpack 本身就有的 dev-server!

基于 webpack5 和 websocket, 实现浏览器扩展(插件)开发阶段编译完成自动刷新功能!**此版本为破坏性重构版,不兼容历史版本**

安装使用:

  1. 安装
npm install ws-reload-plugin --save-dev
  1. webpack.config.js 配置文件中引入此模块,必须传入 content 和 background 的编译输出文件名,比如你打包后的文件目录是 dist/content.js 和 dist/service/background.js, 则按下面传参;
const { wsAutoReloadPlugin } = require("ws-reload-plugin");
plugins: [
  new wsAutoReloadPlugin({
    port: 2021, // 选传,  默认2021
    entryFiles: {
      // 必须传参
      content: "./content.js", // content 输出文件path
      background: "./service/background.js", // background 输出文件path
    },
    autoRun: { content: true, background: true }, // 选传, 默认都为true
  }),
];
  1. 此插件会自动在 content 文件插入 websocket 代码, 创建一个createWsConnect函数, background 文件插入监听代码, 创建一个bgdListenMsg函数, 默认会直接在顶层调用`
  2. 如果你想在 content 里自定义控制创建调用, 比如只想在某些页面挂载,请传入参数 {autoRun: { content: false}}, 然后自行调用函数createWsConnect()即可

  3. 如果你想在 service worker 里自定义控制监听和刷新时机, 请传入参数 {autoRun: { background: false}}, 然后添加以下代码到你的自定义逻辑中

//const bgdListenMsg = () => {
//chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message == "compiler") {
  sendResponse("reload successful");
  chrome.tabs.query({ url: sender.url }, ([tab]) => {
    if (tab) {
      chrome.tabs.reload(tab.id);
      chrome.runtime.reload();
    }
  });
}
//  });
//};

实现原理:

  • 1.在 node 环境下创建 websocket 服务端与客户端,每次编译完成后通过 webpack 钩子(hook)发送信息给 content 客户端;(为什么不直接发送给 background?因为 v3 改为 service worker,有自动休眠机制)
  • 2.content 客户端收到消息后再发送给 service worker(background)
  • 3.service worker 监听命令并执行刷新