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

@aurouscia/vite-app-version

v0.2.0

Published

vite应用版本标记与检查工具

Readme

vite-app-version

组成部分

  • 一个vite插件,在应用编译时将当前时间戳写入:
    • index.html的meta标签里
    • public目录的某文件里(作为静态文件被请求)
  • 一个异步函数,在你认为合适的时候进行版本检查(对比上述两者的值是否相同)并返回一个布尔值(客户端是否是最新版)

使用方法

npm install @aurouscia/vite-app-version
//vite.config.[js/ts]
import { appVersionMark } from '@aurouscia/vite-app-version'

export default defineConfig({
    plugins:[
        ...
        appVersionMark()
    ]
})
//xxxx.[vue/js/ts]
//---------------------------------------------
// 注意这里导入的from并不是包名,后面还有个check
//---------------------------------------------
import { appVersionCheck } from '@aurouscia/vite-app-version/check';

//用户进入特定页面等场景
const isNewest = await appVersionCheck()
if(!isNewest){
    alert('有新版本,请刷新浏览器更新')
    //或者直接location.reload()
}

为什么导入路径不一样?

因为mark函数里用到了node的fs模块,而check函数并不用。
如果从同一个入口导入,vite会一股脑解析所有依赖项,并对“浏览器使用fs”(其实并没有)这件事发出警告,看起来很让人不爽。

调试时

若调试时发生“怎么刷新都显示需要更新”的情况,重启vite调试服务器即可。

git

记得将生成的txt文件加入.gitignore里。

自定义文件名称和meta名称

如果不想使用默认的文件名和meta标签名
上述两个函数都可以传入配置参数(切记要保持一致),可这样自定义保存版本信息的文件名和meta标签名。
为了保持一致,可以使用vite的define功能定义这个配置对象。

License

MIT