How sanyuan0704/vite-plugin-chunk-split works
vite-plugin-chunk-split is a Vite plugin that configures Rollup chunk assignment. A developer adds the plugin and selects a strategy or custom rules; during Vite configuration, the plugin builds a manual-chunk callback that classifies modules, optionally scanning imports and resolving package entries. Rollup uses that callback during bundling. The plugin also has a separate renderChunk hook that removes imports from generated commonjs helper chunks. The map is based on the README and sampled source; no separate unsampled product subsystem is evident.
Main entry points: index.ts Chunk strategy · staticImportScan.ts Static import scan · utils.ts Path and package resolution · helper.ts CSS identifier check
Components 10
Plugin lifecycle
- Plugin hooks
src/index.ts - Helper import cleanup
src/index.ts
Chunk splitting
- Chunk strategy
src/index.ts - Custom split rules
src/index.ts
Classification support
- Static import scan
src/staticImportScan.ts - Path and package resolution
src/utils.ts - CSS identifier check
src/helper.ts
Other components
- Plugin user
- Vite
- Rollup bundler
Connections 10
- Plugin user → Plugin hooks: configures
README.md - Vite → Plugin hooks: runs hooks
src/index.ts - Plugin hooks → Chunk strategy: builds callback
src/index.ts - Chunk strategy → Custom split rules: wraps rules
src/index.ts - Chunk strategy → Static import scan: scans imports
src/index.ts - Chunk strategy → CSS identifier check: checks CSS
src/index.ts - Custom split rules → Path and package resolution: resolves packages
src/index.ts - Plugin hooks → Rollup bundler: sets manualChunks
src/index.ts - Rollup bundler → Chunk strategy: classifies modules
- Vite → Helper import cleanup: runs render hook
src/index.ts