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

vite-plugin-split-chunk

v0.5.0

Published

A vite plugin for better chunk split

Downloads

2

Readme

vite-plugin-split-chunk

Vite 代码拆包插件。支持多种拆包策略,可避免手动操作 manualChunks 潜在的循环依赖问题。

基本使用

首先安装依赖:

// use npm
npm i vite-plugin-split-chunk -D
// use yarn
yarn add vite-plugin-split-chunk -D
// use pnpm
pnpm i vite-plugin-split-chunk -D

然后你可以在 Vite 配置文件中使用它:

// vite.config.ts
import { chunkSplitPlugin } from 'vite-plugin-split-chunk'

{
  plugins: [
    // ...
    chunkSplitPlugin()
  ]
}

参数类型

type packageInfo = string | RegExp
type Strategy =
  // 默认拆包方式
  | 'default'
  // 所有文件打包到一起
  | 'all-in-one'
  // 实现不打包的效果,一个文件一个 chunk
  | 'unbundle'

export type CustomSplitting = Record<string, packageInfo[]>

export interface ChunkSplitOptions {
  strategy?: Strategy
  customSplitting?: CustomSplitting
}

你也可以使用插件的配置来精细化地控制拆包策略:

// vite.config.ts
import { chunkSplitPlugin } from 'vite-plugin-split-chunk'

{
  plugins: [
    // ...
    chunkSplitPlugin({
      strategy: 'default',
      customSplitting: {
        // `react` and `react-dom` 会被打包到一个名为`render-vendor`的 chunk 里面(包括它们的一些依赖,如 object-assign)
        'react-vendor': ['react', 'react-dom'],
        // 源码中 utils 目录的代码都会打包进 `utils` 这个 chunk 中
        utils: [/src\/utils/]
      }
    })
  ]
}

另外,你也可以实现一键实现不打包(Bundleless),同时通过customSplitting参数来指定文件合并的策略:

// vite.config.ts
import { chunkSplitPlugin } from 'vite-plugin-split-chunk'

{
  plugins: [
    // ...
    chunkSplitPlugin({
      strategy: 'unbundle',
      customSplitting: {
        // src/container 下的所有文件会被合并成一个 chunk
        container: [/src\/container/]
      }
    })
  ]
}

License

MIT