bundle-cop-vercel-plugin
v0.1.3
Published
Next.js adapter that attributes bundle cost to source files and enforces budgets
Maintainers
Readme
bundle-cop-vercel-plugin
Next.js adapter that attributes client bundle cost to the importing source file and enforces size budgets during next build.
| | |
|---|---|
| Docs | bundle-cop.vercel.app/docs |
| npm | bundle-cop-vercel-plugin |
| Source | nad33mahm3d/bundle-cop-vercel-plugin (packages/vercel-plugin) |
| Changelog | CHANGELOG.md |
| Issues | GitHub Issues |
Part of Bundle Cop (adapter + Vercel integration app).
Requirements
- Next.js 16+ (
adapterPath/ Adapters API) - Node.js 20+
Install
pnpm add bundle-cop-vercel-plugin
# npm i bundle-cop-vercel-plugin
# yarn add bundle-cop-vercel-pluginSetup
// next.config.ts
import type { NextConfig } from 'next'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const nextConfig: NextConfig = {
adapterPath: require.resolve('bundle-cop-vercel-plugin/adapter'),
}
export default nextConfigUse the /adapter export. Next loads adapters via require.resolve + ESM interop; the dedicated adapter entry exposes onBuildComplete correctly.
Optional budgets
Create bundle-cop.config.json in the project root:
{
"budgets": [
{ "path": "/*", "maxSize": "250kb", "enforce": "warn" },
{ "path": "/dashboard", "maxSize": "400kb", "enforce": "error" }
],
"ignore": [],
"suggestions": true,
"githubComment": true
}enforce: "warn"— logs over-budget routesenforce: "error"— fails the build
What it does
On onBuildComplete:
- Parses
.nextdiagnostics when present; otherwise uses route/chunk fallbacks (Turbopack-friendly) - Attributes known heavy packages (e.g.
moment,lodash) to the importing source file - Enforces budgets from
bundle-cop.config.json - Writes
bundle-report.json(and under.vercel/output/static/when possible) - Uploads a private Blob report when
BLOB_READ_WRITE_TOKENis set
Environment (optional)
| Variable | Purpose |
|----------|---------|
| BLOB_READ_WRITE_TOKEN | Upload private report to Vercel Blob |
| VERCEL_GIT_COMMIT_SHA / GITHUB_SHA | Report key (commit SHA) |
Releases
Versions are published from GitHub Releases. Tag vX.Y.Z → CI publishes the same version to npm. See the repo README.
