Registry / web-framework / vite-plugin-qiankun

vite-plugin-qiankun

JSON →
library1.0.15jsnpmunverified

A Vite plugin that enables seamless integration of Vite-based micro-frontends into the qiankun framework. Version 1.0.15, stable, with moderate release cadence. It preserves Vite's ESM advantages and supports development mode, but note that ESM modules conflict with qiankun's JS sandbox, so the plugin works without sandboxing. You must manually handle global state via `qiankunWindow`. Alternative to using webpack with qiankun.

npm install vite-plugin-qiankun
INSTALL
IMPORT
SIG · VITE-PLUGIN-QIANKU
V
vite-plugin-qiankun
web-frameworkjavascriptv1.0.15
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import qiankun from 'vite-plugin-qiankun'
✗ const qiankun = require('vite-plugin-qiankun')
Plugin is ESM-only, no CJS support.
renderWithQiankun
✓ import { renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
✗ import { renderWithQiankun } from 'vite-plugin-qiankun'
Must import helper functions from the 'dist/helper' subpath.
qiankunWindow
✓ import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
✗ import qiankunWindow from 'vite-plugin-qiankun/dist/helper'
qiankunWindow is a named export, not default.
qiankunWindow.__POWERED_BY_QIANKUN__
✓ import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; if (qiankunWindow.__POWERED_BY_QIANKUN__) {}
✗ if (window.__POWERED_BY_QIANKUN__) {}
Must use the exported qiankunWindow object instead of window.

Shows how to install the plugin, configure lifecycle hooks, and handle standalone vs qiankun mode.

// vite.config.ts import qiankun from 'vite-plugin-qiankun'; export default { plugins: [qiankun('myMicroAppName')], base: 'http://localhost:5173/' } // main.ts (React example) import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; function render(props = {}) { const { container } = props; ReactDOM.render(<App />, container?.querySelector('#root') || document.getElementById('root')); } renderWithQiankun({ mount(props) { render(props); }, bootstrap() { console.log('bootstrap'); }, unmount(props) { const { container } = props; ReactDOM.unmountComponentAtNode(container?.querySelector('#root') || document.getElementById('root')); } }); if (!qiankunWindow.__POWERED_BY_QIANKUN__) { render({}); }
Debug
Known issues
gotchaNo JS sandbox: Because Vite loads ESM modules, qiankun's sandbox is not enabled. Global variables set via `window` may leak to other micro-apps.
fix
Use `qiankunWindow` object instead of `window` to set properties, which provides a lightweight proxy.
affects: *
gotchaIn development mode, the plugin conflicts with Vite's HMR (e.g., @vitejs/plugin-react-refresh). You cannot use both simultaneously.
fix
Toggle between `useDevMode: true` (no HMR) and `useDevMode: false` (HMR but not in qiankun).
affects: *
gotchaMust set `base` option in Vite config to the production URL, otherwise assets may not load in qiankun.
fix
Set `base: 'http://your-deploy-url.com/'` in vite.config.ts.
affects: *
deprecatedPlugin API may change as it relies on undocumented Vite internals.
fix
Keep plugin version in sync with Vite version and monitor for breaking changes.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-qiankun/dist/helper' or its corresponding type declarations.
TypeScript cannot resolve the helper subpath because it's not exported in package.json 'exports' field.
fix
Add `"exports": { "./dist/helper": "./dist/helper.js" }` to your tsconfig.json or use `// @ts-ignore`.
Uncaught SyntaxError: The requested module 'vite-plugin-qiankun' does not provide an export named 'default'
Using CommonJS `require()` instead of ESM import.
fix
Use `import qiankun from 'vite-plugin-qiankun'` and ensure your project is ESM.
Failed to fetch dynamically imported module: http://localhost:5173/...
In development, the micro-app's origin differs from the main app's origin. Vite dev server's base URL is not correct.
fix
Set `base: 'http://localhost:5173/'` in vite.config.ts and ensure CORS headers are properly configured.
Lifecycle function 'mount' not triggered when loading micro-app in qiankun.
The `renderWithQiankun` function was not called correctly or not imported from the correct path.
fix
Import `renderWithQiankun` from `'vite-plugin-qiankun/dist/helper'` and call it with the correct lifecycle object.
Upgrade
Version history
1.0.15latest on npm
Audit
Dependencies
viterequiredcore peer dependency for plugin
typescriptoptionalpeer dependency for TypeScript support
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
vite-plugin-qiankun — npm install vite-plugin-qiankun · libregistry