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

vite-plugin-qiankun-obfuscator

v1.0.2

Published

Vite 插件:在生产构建时混淆业务代码,且不破坏 qiankun 微前端集成。

Readme

vite-plugin-qiankun-obfuscator

生产构建 时混淆前端业务代码,保护源码,且 不破坏 qiankun 微前端集成 的 Vite 插件。

特性

  • 🛡️ qiankun 安全:自动保留 __POWERED_BY_QIANKUN____INJECTED_PUBLIC_PATH_BY_QIANKUN____webpack_public_path__moudleQiankunAppLifeCycles 及应用名等集成红线;默认关闭在沙箱里会出问题的 selfDefending / debugProtection
  • 🎯 只混淆业务代码:自动把第三方依赖拆到独立 vendor chunk 并跳过混淆——既无意义又拖慢构建的开源库不参与混淆。
  • 仅生产构建生效:dev / vite serve / qiankun useDevMode 调试完全不受影响。
  • 🎚️ 三档强度light / medium(默认)/ strong,可深度覆盖。

安装

npm i -D vite-plugin-qiankun-obfuscator

插件已内置依赖 javascript-obfuscator,无需单独安装。

一键接入

// vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import qiankun from 'vite-plugin-qiankun';
import qiankunObfuscator from 'vite-plugin-qiankun-obfuscator';

const APP_NAME = 'my-sub-app';

export default defineConfig({
  plugins: [
    vue(),
    qiankun(APP_NAME, { useDevMode: true }),
    // 放在最后即可;只在 vite build 时生效
    qiankunObfuscator({ appName: APP_NAME }),
  ],
});

就这一行。运行 vite build 后,业务 chunk 会被混淆,vendor chunk 保持原样,qiankun 生命周期挂载不受影响。

非 qiankun 项目

普通 SPA / 主应用也能用,省略 appName 即可:

qiankunObfuscator()

选项

| 选项 | 类型 | 默认 | 说明 | |---|---|---|---| | appName | string | — | qiankun 微应用名,与 qiankun(name) 一致;非 qiankun 项目可省略 | | level | 'light' \| 'medium' \| 'strong' | 'medium' | 混淆强度 | | enable | boolean | 仅生产 build | 传 false 整体关闭 | | splitVendor | boolean | true | 自动注入 manualChunks 拆 vendor;若你已自定义 manualChunks 则自动让位 | | skipChunkPrefixes | string[] | ['vendor'] | 跳过混淆的 chunk 文件名前缀 | | include | (string\|RegExp)[] | — | 仅混淆匹配的 chunk | | exclude | (string\|RegExp)[] | — | 额外排除的 chunk(优先级高于 include) | | reservedStrings | string[] | — | 追加保留字符串(正则) | | reservedNames | string[] | — | 追加保留标识符(正则) | | obfuscatorOptions | ObfuscatorOptions | — | 深度覆盖 javascript-obfuscator 选项 | | log | boolean | true | 打印混淆汇总日志 |

强度对比

| 强度 | 变换 | 构建耗时 | 产物体积 | 运行时损耗 | |---|---|---|---|---| | light | 字符串数组 + 标识符重命名 | 快 | 几乎不变 | 可忽略 | | medium | + 字符串编码/旋转/分割 + 数字表达式化 | 中 | 略增 | 可忽略 | | strong | + 控制流扁平化 + 死代码注入 + rc4 | 慢 | 明显增大 | 可感知 |

⚠️ 注意

  • 不要通过 obfuscatorOptions 打开 selfDefendingdebugProtection:它们在 qiankun 的 Proxy 沙箱里会误伤甚至卡死。
  • appName 必须与 qiankun() 注册名一致,否则混淆白名单不对应(虽然字符串值仍会保留,但建议显式传入)。
  • 集成上线前,建议在真实主应用里用 qiankun 实际挂载一次子应用做最终冒烟验证。

License

MIT