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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cherishtao/vite-plugin-langspack

v0.1.7

Published

- 辅助一种项目国际化模式:开发阶段采用多目录结构开发,便于开发人员查看和修改;发布时采用每语言单一翻译文件独立发布方式,便于客户定制和后期修改维护 - <a href="https://github.com/CherishMvp/vite-plugin-langspack/" target="_blank">预览</a> - <a href="https://www.npmjs.com/package/@cherishtao/vite-plugin-langspack" target="_blank

Readme

@cherishtao/vite-plugin-langspack

介绍

  • 辅助一种项目国际化模式:开发阶段采用多目录结构开发,便于开发人员查看和修改;发布时采用每语言单一翻译文件独立发布方式,便于客户定制和后期修改维护
  • 预览
  • npmjs

安装

  • pnpm i -D @cherishtao/vite-plugin-langspack

用法

  • 详细内容可以参考项目示例和源码;有问题请提 issue
  • 补充:对于不需要区分生产模式,只要直接打包语言文件的场景,可以在 vite.config.ts 中硬指定参数 mode='development'来实现
// vite.config.ts
import vitePluginLangspack from '@lazebird/vite-plugin-langspack';
vitePlugins.push(vitePluginLangspack({ lang: { src: pathResolve('langs'), dst: pathResolve('public'), include: /.json$/ }, log: { level: 6 } }));

// 业务
import getLocaleData from 'virtual:langs';
const msgs = await getLocaleData(locale);

Todo

  • [x] 去掉配置中的 mode 字段,简化配置
  • [ ] 未使用的 key 的 treeshake
  • [ ] 不同 key 相同翻译内容的合并

问题

~~Unknown variable dynamic import~~

  • import 默认需要实体文件,因此在项目 langs/目录存在 2 个空文件 zh_CN.js 和 en_US.js;否则插件不会处理该 import 资源
  • 且在外扩新语种时,比如 zh_TW,由于编译时 import 未处理该文件,也会导致出错,可选自行处理该问题,做法参考
let msgs = [];
if (import.meta.env.DEV) msgs = await (await import(`../../../langs/${locale}.js`))?.default;
else msgs = await (await axios.get(`/${locale}.json`)).data;
  • 考虑后续通过虚拟模块重构来解决该问题,并且将语言作为一个参数项而非路径项