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

ja-web-version-update-checker

v1.0.0

Published

A framework-agnostic version update prompt for Webpack and Vite.

Readme

ja-web-version-update-checker

一个独立、无外部依赖的前端版本更新提示器。同时兼容 Webpack 和 Vite。

该包提供了一个高颜值的 UI 组件,用于在系统发布新版本时,在右下角优雅地提示用户刷新页面。其原理是在打包(build)阶段自动生成一个 version.json,并在浏览器运行时在后台静默轮询对比版本差异。

核心特性

  • 框架无关:完美兼容 Vue、React 或是原生 JavaScript 项目。
  • 开箱即用的构建插件:内置了 Webpack 和 Vite 两种构建工具的专属插件。
  • 零外部依赖:基于原生 JavaScript 和原生 DOM API 实现,无需引入 Element UI、Ant Design 或 Axios。
  • 高颜值 UI:自带平滑的滑入滑出动画、悬浮光影交互,并支持 light (浅色) 与 dark (深色科技风) 双主题。
  • 性能友好:在后台静默轮询,结合 visibilitychange 事件,仅在用户可见活跃状态时触发版本对比。

安装

npm install ja-web-version-update-checker --save

快速上手

1. 注入构建插件(生成版本文件)

如果你使用 Webpack (如 Vue CLI 架构)

在您的 vue.config.jswebpack.config.js 中:

const WebpackVersionPlugin = require('ja-web-version-update-checker/src/webpack-plugin');

module.exports = {
  configureWebpack: config => {
    // 建议仅在生产或测试环境下开启
    if (process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test") {
      config.plugins.push(new WebpackVersionPlugin());
    }
  }
}

如果你使用 Vite

在您的 vite.config.js 中:

import { defineConfig } from 'vite';
import ViteVersionPlugin from 'ja-web-version-update-checker/src/vite-plugin';

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

2. 初始化运行时(监听版本更新)

在您应用的总入口文件(例如 main.jsindex.js)中引入并启动它:

import { startVersionCheck } from 'ja-web-version-update-checker';

// 建议仅在生产或测试环境下开启
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') {
  startVersionCheck({
    publicPath: process.env.BASE_URL || '/', // 请确保此处与您项目打包的 publicPath 一致
    pollingInterval: 5, // 每 5 分钟轮询一次
    theme: 'dark' // 可选 'dark' (深色) 或 'light' (浅色)
  });
}

配置项 (Options)

startVersionCheck 支持传入以下参数对象:

| 属性名 | 类型 | 默认值 | 描述 | | --- | --- | --- | --- | | publicPath | String | / | 项目部署的基准路径,用于寻找 version.json 的准确位置。 | | pollingInterval | Number | 5 | 轮询服务端版本号的时间间隔(单位:分钟)。 | | theme | String | 'dark' | 弹窗的 UI 主题,目前支持 'dark''light'。 | | title | String | '🎉 系统更新提示' | 弹窗标题文字,可按需自定义。 | | description | String | '系统发布了新版本...' | 弹窗的主体描述内容,可按需自定义。 | | buttonText | String | '✨ 立即刷新体验' | 刷新按钮的文字,可按需自定义。 |

License

MIT