bundle-cop-vercel-plugin 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -13
- package/package.json +17 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nadeem Ahmed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
# bundle-cop-vercel-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/bundle-cop-vercel-plugin)
|
|
4
|
+
[](https://www.npmjs.com/package/bundle-cop-vercel-plugin)
|
|
5
|
+
[](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/actions/workflows/publish-npm.yml)
|
|
7
|
+
|
|
8
|
+
Next.js **adapter** that attributes client bundle cost to the importing source file and enforces size budgets during `next build`.
|
|
9
|
+
|
|
10
|
+
| | |
|
|
11
|
+
|---|---|
|
|
12
|
+
| **npm** | [bundle-cop-vercel-plugin](https://www.npmjs.com/package/bundle-cop-vercel-plugin) |
|
|
13
|
+
| **Source** | [nad33mahm3d/bundle-cop-vercel-plugin](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin) (`packages/vercel-plugin`) |
|
|
14
|
+
| **Changelog** | [CHANGELOG.md](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/blob/main/CHANGELOG.md) |
|
|
15
|
+
| **Issues** | [GitHub Issues](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/issues) |
|
|
16
|
+
|
|
17
|
+
Part of the [Bundle Cop](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin) monorepo (adapter + Vercel integration app).
|
|
4
18
|
|
|
5
19
|
## Requirements
|
|
6
20
|
|
|
7
|
-
- Next.js
|
|
8
|
-
- Node.js 20
|
|
21
|
+
- **Next.js 16+** (`adapterPath` / Adapters API)
|
|
22
|
+
- **Node.js 20+**
|
|
9
23
|
|
|
10
24
|
## Install
|
|
11
25
|
|
|
12
26
|
```bash
|
|
13
27
|
pnpm add bundle-cop-vercel-plugin
|
|
14
|
-
#
|
|
28
|
+
# npm i bundle-cop-vercel-plugin
|
|
29
|
+
# yarn add bundle-cop-vercel-plugin
|
|
15
30
|
```
|
|
16
31
|
|
|
17
32
|
## Setup
|
|
@@ -30,27 +45,48 @@ const nextConfig: NextConfig = {
|
|
|
30
45
|
export default nextConfig
|
|
31
46
|
```
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
Use the **`/adapter`** export. Next loads adapters via `require.resolve` + ESM interop; the dedicated adapter entry exposes `onBuildComplete` correctly.
|
|
49
|
+
|
|
50
|
+
### Optional budgets
|
|
51
|
+
|
|
52
|
+
Create `bundle-cop.config.json` in the project root:
|
|
34
53
|
|
|
35
54
|
```json
|
|
36
55
|
{
|
|
37
56
|
"budgets": [
|
|
38
|
-
{ "path": "/*", "maxSize": "250kb", "enforce": "warn" }
|
|
57
|
+
{ "path": "/*", "maxSize": "250kb", "enforce": "warn" },
|
|
58
|
+
{ "path": "/dashboard", "maxSize": "400kb", "enforce": "error" }
|
|
39
59
|
],
|
|
40
|
-
"
|
|
60
|
+
"ignore": [],
|
|
61
|
+
"suggestions": true,
|
|
62
|
+
"githubComment": true
|
|
41
63
|
}
|
|
42
64
|
```
|
|
43
65
|
|
|
66
|
+
- `enforce: "warn"` — logs over-budget routes
|
|
67
|
+
- `enforce: "error"` — fails the build
|
|
68
|
+
|
|
44
69
|
## What it does
|
|
45
70
|
|
|
46
71
|
On `onBuildComplete`:
|
|
47
72
|
|
|
48
|
-
1. Parses `.next` diagnostics /
|
|
49
|
-
2. Attributes heavy packages (e.g. `moment`) to the importing file
|
|
50
|
-
3.
|
|
51
|
-
4. Writes `bundle-report.json`
|
|
52
|
-
5. Uploads
|
|
73
|
+
1. Parses `.next` diagnostics when present; otherwise uses route/chunk fallbacks (Turbopack-friendly)
|
|
74
|
+
2. Attributes known heavy packages (e.g. `moment`, `lodash`) to the importing source file
|
|
75
|
+
3. Enforces budgets from `bundle-cop.config.json`
|
|
76
|
+
4. Writes `bundle-report.json` (and under `.vercel/output/static/` when possible)
|
|
77
|
+
5. Uploads a **private** Blob report when `BLOB_READ_WRITE_TOKEN` is set
|
|
78
|
+
|
|
79
|
+
## Environment (optional)
|
|
80
|
+
|
|
81
|
+
| Variable | Purpose |
|
|
82
|
+
|----------|---------|
|
|
83
|
+
| `BLOB_READ_WRITE_TOKEN` | Upload private report to Vercel Blob |
|
|
84
|
+
| `VERCEL_GIT_COMMIT_SHA` / `GITHUB_SHA` | Report key (commit SHA) |
|
|
85
|
+
|
|
86
|
+
## Releases
|
|
87
|
+
|
|
88
|
+
Versions are published from GitHub Releases. Tag `vX.Y.Z` → CI publishes the same version to npm. See the [repo README](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin#publishing-the-npm-package).
|
|
53
89
|
|
|
54
90
|
## License
|
|
55
91
|
|
|
56
|
-
MIT
|
|
92
|
+
[MIT](https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bundle-cop-vercel-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Next.js adapter that attributes bundle cost to source files and enforces budgets",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Nadeem Ahmed",
|
|
8
|
+
"url": "https://github.com/nad33mahm3d"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "./dist/index.js",
|
|
8
12
|
"types": "./dist/index.d.ts",
|
|
@@ -18,12 +22,14 @@
|
|
|
18
22
|
"require": "./next-adapter.cjs",
|
|
19
23
|
"import": "./next-adapter.cjs",
|
|
20
24
|
"default": "./next-adapter.cjs"
|
|
21
|
-
}
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
22
27
|
},
|
|
23
28
|
"files": [
|
|
24
29
|
"dist",
|
|
25
30
|
"next-adapter.cjs",
|
|
26
|
-
"README.md"
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
27
33
|
],
|
|
28
34
|
"scripts": {
|
|
29
35
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
@@ -35,7 +41,7 @@
|
|
|
35
41
|
"node": ">=20"
|
|
36
42
|
},
|
|
37
43
|
"peerDependencies": {
|
|
38
|
-
"next": ">=
|
|
44
|
+
"next": ">=16.0.0"
|
|
39
45
|
},
|
|
40
46
|
"dependencies": {
|
|
41
47
|
"@vercel/blob": "^2.8.0"
|
|
@@ -47,16 +53,20 @@
|
|
|
47
53
|
"typescript": "^5.8.2"
|
|
48
54
|
},
|
|
49
55
|
"publishConfig": {
|
|
50
|
-
"access": "public"
|
|
56
|
+
"access": "public",
|
|
57
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
58
|
},
|
|
52
59
|
"keywords": [
|
|
53
60
|
"nextjs",
|
|
61
|
+
"next.js",
|
|
54
62
|
"vercel",
|
|
55
63
|
"bundle",
|
|
64
|
+
"bundle-size",
|
|
56
65
|
"webpack",
|
|
57
66
|
"turbopack",
|
|
58
67
|
"adapter",
|
|
59
|
-
"budget"
|
|
68
|
+
"budget",
|
|
69
|
+
"performance"
|
|
60
70
|
],
|
|
61
71
|
"repository": {
|
|
62
72
|
"type": "git",
|
|
@@ -66,5 +76,5 @@
|
|
|
66
76
|
"bugs": {
|
|
67
77
|
"url": "https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/issues"
|
|
68
78
|
},
|
|
69
|
-
"homepage": "https://github.com/nad33mahm3d/bundle-cop-vercel-plugin#readme"
|
|
79
|
+
"homepage": "https://github.com/nad33mahm3d/bundle-cop-vercel-plugin/tree/main/packages/vercel-plugin#readme"
|
|
70
80
|
}
|