start-vibing-stacks 2.21.0 → 2.22.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing-stacks",
3
- "version": "2.21.0",
3
+ "version": "2.22.0",
4
4
  "description": "AI-powered multi-stack dev workflow for Claude Code. Supports PHP, Node.js, Python and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,10 @@
1
1
  ---
2
2
  name: debugging-patterns
3
- version: 1.0.0
3
+ version: 1.1.0
4
+ description: Universal debugging strategies plus the "Bundle, not Backend"
5
+ triage for silent wrong-component renders (HTTP 200, empty server logs,
6
+ wrong default export shipped). Pairs with `inertia-react` "Vite Build
7
+ Gotchas" section.
4
8
  ---
5
9
 
6
10
  # Debugging Patterns
@@ -34,6 +38,72 @@ node --inspect script.js
34
38
  DEBUG=* node script.js
35
39
  ```
36
40
 
41
+ ## Bundle, not Backend (silent wrong-component / wrong-output renders)
42
+
43
+ > **When the server returns HTTP 200, server logs are empty, and the browser
44
+ > still renders the wrong content — STOP debugging the server.** The bug is
45
+ > in the bundle. This is the #1 source of "Sonnet runs in circles for 90
46
+ > minutes" debugging sessions.
47
+
48
+ ### Symptoms that point to the bundle, not the server
49
+
50
+ | Symptom | Why it implicates the bundle |
51
+ |---|---|
52
+ | HTTP 200 on every request, browser shows wrong content | Server is producing correct payload; client is misresolving it |
53
+ | Empty server logs (Laravel/Node/Python) | No exception was thrown; backend is genuinely correct |
54
+ | The wrong component/page/template is rendered | Default export of the loaded chunk is not the expected one |
55
+ | Reverting the last `vite.config.js` / `webpack.config.js` / `rollup.config.js` change fixes it | Build graph is the locus |
56
+ | Only happens after `npm run build` (dev works) | Production chunking heuristics differ from dev's per-file modules |
57
+ | Different routes resolve to the same JS asset URL | Resolve-map collision in `import.meta.glob` / module federation |
58
+
59
+ ### Triage protocol (5 steps, ~3 minutes)
60
+
61
+ 1. **Confirm the payload** — DevTools → Network → click the HTML/XHR request
62
+ for the broken route → inspect the response. If the server-side identifier
63
+ (`component:` for Inertia, route name for Next.js RSC, etc.) is the EXPECTED
64
+ one, the server is correct. Move to step 2.
65
+ 2. **Find the JS chunk that loaded** — in the same Network tab, look at the
66
+ `.js` requests that fired after the page request. For SPA frameworks, one
67
+ of them is the page chunk. Note its URL/hash.
68
+ 3. **Inspect the chunk's `default` export** — open the chunk URL in a new tab,
69
+ `Ctrl+F` for `default:` / `export{` / `as default}`. Identify the actual
70
+ component name being exported.
71
+ 4. **Compare** — if (chunk's default export) ≠ (server's component identifier),
72
+ confirmed: the bug is in the bundle. Possible causes (in order of likelihood):
73
+ - `manualChunks` collided with an `entry` chunk (Rollup/Rolldown silently
74
+ dropped a group — see `inertia-react §Vite Build Gotchas`)
75
+ - Two files with the same default export name caused a hash reuse
76
+ - A barrel/re-export chain has the wrong file at the top
77
+ - Tree-shaking removed the expected export because it was only referenced
78
+ conditionally
79
+ 5. **Bisect on the build config** — revert the last commit that touched
80
+ `vite.config.*`, `rollup.config.*`, `webpack.config.*`, `next.config.*`,
81
+ `turbo.json`, or any chunking-related setting. If the bug disappears,
82
+ you've located it. Do NOT debug the server.
83
+
84
+ ### Common causes (multi-stack)
85
+
86
+ | Stack | Pattern | Fix reference |
87
+ |---|---|---|
88
+ | Laravel + Inertia + Vite | Same module in `laravel.input[]` AND `Pages/**` glob | `inertia-react §Vite Build Gotchas` |
89
+ | Next.js App Router | Server/Client component boundary mis-resolved by bundler split | Check `'use client'` placement, then `next.config.mjs` |
90
+ | Module Federation | Remote chunk hash mismatch after redeploy | Force remote re-fetch, check `shared` deps versions |
91
+ | Webpack 5 | `splitChunks.cacheGroups` overlap with `entry` | Same class of bug as Vite manualChunks |
92
+ | esbuild | Two CJS modules with same `module.exports.default` deduped | Set `format: 'esm'` or use named exports |
93
+
94
+ ### Validators that catch the bug at build time
95
+
96
+ If a `scripts/check-vite-manifest.mjs` exists in the project (shipped by
97
+ `start-vibing-stacks` for PHP/Laravel projects), run it after every build:
98
+
99
+ ```bash
100
+ node scripts/check-vite-manifest.mjs
101
+ ```
102
+
103
+ It cross-references `laravel.input[]` against `import.meta.glob` patterns and
104
+ fails the build if any module appears in both — which is the Laravel/Inertia
105
+ specific shape of "Bundle, not Backend."
106
+
37
107
  ## Anti-Patterns
38
108
 
39
109
  | Don't | Do |
@@ -42,3 +112,6 @@ DEBUG=* node script.js
42
112
  | Fix symptom, not cause | Trace to root cause |
43
113
  | Skip writing test for fix | Always add regression test |
44
114
  | Leave debug code in commit | Clean before commit |
115
+ | Debug the server when HTTP 200 + empty logs + wrong content | Triage as "Bundle, not Backend" — start from the chunk graph |
116
+ | Trust that `manualChunks` / `splitChunks` always honors your grouping | Bundlers silently drop groups when they collide with entry chunks |
117
+ | Move on after one `npm run build` succeeded | Run the manifest validator; bundlers don't warn on collision |
@@ -1,10 +1,13 @@
1
1
  ---
2
2
  name: inertia-react
3
- version: 2.0.0
3
+ version: 2.1.0
4
4
  description: LEGACY skill — Inertia.js + React frontend integration with
5
5
  Laravel-rendered pages. Use ONLY in pre-existing Inertia projects. For NEW
6
6
  projects use the `react-api` frontend stack (`axios-laravel-api` +
7
- `react-api-standards`) which decouples render from data fetching.
7
+ `react-api-standards`) which decouples render from data fetching. v2.1.0 adds
8
+ the "Vite Build Gotchas" section covering the `manualChunks` × entry-chunk
9
+ × `resolvePageComponent` glob interaction that produces silent
10
+ wrong-component renders (production post-mortem 2026-05).
8
11
  ---
9
12
 
10
13
  # Inertia.js + React Integration (LEGACY)
@@ -343,6 +346,138 @@ router.reload({ only: ['stats'] }); // Partial reload
343
346
  - Access shared props via `usePage().props`
344
347
  - `processing` boolean from `useForm` for button loading states
345
348
 
349
+ ## Vite Build Gotchas (Inertia-specific)
350
+
351
+ > **Production post-mortem 2026-05.** Reverting/rebuilding `vite.config.js`
352
+ > chunking in an Inertia + Laravel project can produce a **silent wrong-component
353
+ > render** (Login renders HttpErrorPage with HTTP 200, no console errors, empty
354
+ > Laravel logs). The bug lives in the bundle graph, not the server.
355
+
356
+ ### The three-way collision
357
+
358
+ ```
359
+ laravel-vite-plugin ┐
360
+ laravel({ input: [ │ Anything here becomes an ENTRY chunk.
361
+ '.../HttpErrorPage' │ Rollup/Rolldown ALWAYS prioritizes entries.
362
+ ]}) ┘
363
+
364
+ @inertiajs/react ┐
365
+ resolvePageComponent( │ Builds a STATIC resolve-map at build time
366
+ `./Pages/${name}.jsx`,│ via import.meta.glob. The map points each
367
+ import.meta.glob( │ Page path to whatever chunk hash Rollup
368
+ './Pages/**/*.jsx') │ ended up putting that module in.
369
+ ) ┘
370
+
371
+ build.rollupOptions ┐
372
+ .manualChunks(id) { │ This is ADVISORY. Returning 'pages-auth' for
373
+ if (/Auth\//.test(id))│ a module that is ALSO an entry has NO EFFECT.
374
+ return 'pages-auth' │ The grouping is silently dropped — no warning.
375
+ } ┘
376
+ ```
377
+
378
+ When the same module (e.g. `HttpErrorPage.jsx`) is:
379
+
380
+ 1. listed in `laravel.input[]` (because `app.blade.php` has a direct
381
+ `@vite('resources/js/Pages/.../HttpErrorPage.jsx')` for the error layout), AND
382
+ 2. caught by `manualChunks` returning `'pages-auth'`,
383
+
384
+ …Rollup/Rolldown creates a **standalone entry chunk** containing ONLY
385
+ `HttpErrorPage`. The `pages-auth` group is reduced to that one module, and the
386
+ `import.meta.glob` resolve-map points **every sibling** (`Login`, `Register`,
387
+ `ForgotPassword`, …) at that same chunk hash. The siblings' code is discarded.
388
+
389
+ Symptom: `Inertia::render('Auth/Login', …)` returns 200 OK with a valid Inertia
390
+ payload. The browser fetches the chunk listed in the resolve-map. That chunk's
391
+ `default` export is `HttpErrorPage`. The error page is rendered. Backend is
392
+ perfect; frontend lies.
393
+
394
+ ### Rule 1 — Never duplicate a module between `laravel.input` and the glob
395
+
396
+ If a page MUST be referenced directly by `@vite()` in a blade file (typical
397
+ cases: error pages, mail templates rendered server-side, OG/share-image
398
+ renderers), it becomes an entry chunk. You have two options:
399
+
400
+ - **A. Exclude it from the glob** — change `resolvePageComponent`'s glob to
401
+ ignore that path, OR
402
+ - **B. Short-circuit `manualChunks` BEFORE any grouping rule** so the entry
403
+ chunk's identity is preserved without polluting a group.
404
+
405
+ Pattern B (preferred — works without touching the Inertia bootstrap):
406
+
407
+ ```js
408
+ // vite.config.js
409
+ build: {
410
+ rollupOptions: {
411
+ output: {
412
+ manualChunks(id) {
413
+ if (!id.includes('/resources/js/Pages/')) return;
414
+
415
+ // Entry chunks referenced directly by @vite() in blade MUST
416
+ // return undefined here — BEFORE any grouping rule.
417
+ // Otherwise the group is collapsed into the entry and the
418
+ // import.meta.glob resolve-map points siblings at the wrong
419
+ // chunk hash. See "Vite Build Gotchas" in inertia-react skill.
420
+ if (id.includes('/Pages/OtherPages/HttpErrorPage')) return;
421
+
422
+ if (id.includes('/Pages/Auth/') || id.includes('/Pages/OtherPages/')) {
423
+ return 'pages-auth';
424
+ }
425
+ if (id.includes('/Pages/Dashboard/')) {
426
+ return 'pages-dashboard';
427
+ }
428
+ },
429
+ },
430
+ },
431
+ },
432
+ ```
433
+
434
+ ### Rule 2 — `manualChunks` is advisory; entries always win
435
+
436
+ There is no warning when Rollup/Rolldown ignores a `manualChunks` return value
437
+ for an entry module. The validation MUST be done out-of-band on `manifest.json`
438
+ after every build (see `scripts/check-vite-manifest.mjs` shipped by
439
+ `start-vibing-stacks`).
440
+
441
+ ### Rule 3 — Validate `public/build/manifest.json` after every `vite build`
442
+
443
+ ```bash
444
+ # 1. Quick eyeball
445
+ cat public/build/manifest.json | jq 'keys'
446
+
447
+ # 2. Automated (shipped script)
448
+ node scripts/check-vite-manifest.mjs public/build/manifest.json vite.config.js
449
+ ```
450
+
451
+ The script cross-references `laravel.input[]` against the `Pages/**` glob and
452
+ fails (non-zero exit) on any collision.
453
+
454
+ ### Rule 4 — Smoke-test after any `vite.config.js` change touching `build`
455
+
456
+ Three-step browser check for one critical route per page group:
457
+
458
+ 1. DevTools → Network → click the Inertia XHR → read the `component:` field
459
+ in the JSON response.
460
+ 2. Click the JS asset request that followed → open the resolved chunk URL.
461
+ 3. Search for `default:` / `export{ ... as default}` in that chunk. The
462
+ component name MUST match the server's `component:`.
463
+
464
+ If they don't match, the bug is in the chunk graph. Revert the last
465
+ `vite.config.js` change before debugging anything else.
466
+
467
+ ### Why Sonnet (and humans) get stuck on this class of bug
468
+
469
+ | Layer | What it looks like | Why it misleads |
470
+ |---|---|---|
471
+ | Laravel logs | Empty | Backend is genuinely correct |
472
+ | `manifest.json` | Valid, every input has an entry | Manifest doesn't enforce uniqueness across groups |
473
+ | Browser network tab | 200 OK on every request | The wrong JS arrives successfully |
474
+ | Console | Clean | The rendered component is valid React |
475
+
476
+ Triage rule of thumb: **when wrong-component render happens with HTTP 200 and
477
+ empty server logs, the bug is in the bundle. Start from the chunk graph, not
478
+ from Laravel.** This is captured as the "Bundle, not Backend" pattern in
479
+ `debugging-patterns`.
480
+
346
481
  ## Forbidden Patterns
347
482
 
348
483
  | Pattern | Reason | Use Instead |
@@ -354,3 +489,6 @@ router.reload({ only: ['stats'] }); // Partial reload
354
489
  | `window.location` for navigation | Full page reload | `router.visit()` |
355
490
  | `Inertia::render()` after POST | Breaks Inertia protocol | `redirect()->route()` |
356
491
  | Loading all translations globally | Performance waste | On-demand per page route |
492
+ | Same module in `laravel.input[]` AND `Pages/**` glob | Rollup collapses the manual chunk group into the entry; resolve-map points siblings at the wrong chunk (silent wrong-component render) | Short-circuit `manualChunks` with early `return undefined` for entry pages |
493
+ | `manualChunks` grouping pages without running `check-vite-manifest.mjs` | Grouping is advisory and silently ignored for entry chunks | Always run the validator after touching `build.rollupOptions` |
494
+ | Trusting empty Laravel logs as "no bug" | Server can be 100% correct while the bundle ships the wrong default export | Use the "Bundle, not Backend" triage in `debugging-patterns` |
@@ -0,0 +1,309 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * check-vite-manifest.mjs
4
+ *
5
+ * Static validator for Vite + laravel-vite-plugin builds that catches the
6
+ * "entry chunk collides with manualChunks group" bug in Inertia/React apps.
7
+ *
8
+ * Production post-mortem 2026-05: a `vite.config.js` "perf" change added
9
+ * manualChunks(id) { if (/Auth\//.test(id)) return 'pages-auth' }
10
+ * while `laravel.input[]` already listed `Pages/.../HttpErrorPage.jsx`
11
+ * (referenced directly via `@vite()` in `app.blade.php` for the error layout).
12
+ * Rollup/Rolldown silently dropped the manualChunks group, kept only the
13
+ * entry, and the `import.meta.glob` resolve-map in `resolvePageComponent`
14
+ * ended up pointing every sibling page (Login, Register, ForgotPassword) at
15
+ * the same single-module entry chunk. Server sent `component: 'Auth/Login'`,
16
+ * browser rendered HttpErrorPage. HTTP 200. Empty Laravel logs.
17
+ *
18
+ * Rules enforced (all silent failures in Rollup/Rolldown by default):
19
+ *
20
+ * R1. Every path in `laravel.input[]` MUST appear in `manifest.json` with
21
+ * `isEntry: true`.
22
+ * R2. Any `laravel.input[]` path that ALSO matches a `import.meta.glob`
23
+ * pattern in the project's JS is a COLLISION. Either exclude it from
24
+ * the glob, OR short-circuit `manualChunks` with an early
25
+ * `return undefined` before grouping rules.
26
+ * R3. Any file under `resources/js/Pages/` that appears as `isEntry: true`
27
+ * in the manifest is suspect — entry pages must be inspected (they
28
+ * collapse manualChunks groups). If the file is referenced direct via
29
+ * `@vite()` in blade, document it; otherwise treat as a build leak.
30
+ *
31
+ * Usage:
32
+ * node scripts/check-vite-manifest.mjs # auto-detect
33
+ * node scripts/check-vite-manifest.mjs <manifest> <vite.config>
34
+ *
35
+ * Auto-detect order (when no args):
36
+ * manifest: public/build/manifest.json,
37
+ * public/build/.vite/manifest.json
38
+ * vite.config: vite.config.js, vite.config.mjs, vite.config.ts
39
+ *
40
+ * Exit codes:
41
+ * 0 OK (or no Vite/manifest found — skipped)
42
+ * 1 collision (entry × glob) detected
43
+ * 2 manifest missing an `isEntry: true` for a declared input
44
+ * 3 malformed input (could not parse vite.config or manifest)
45
+ */
46
+
47
+ import { readFile, readdir, stat } from 'node:fs/promises';
48
+ import { existsSync } from 'node:fs';
49
+ import { resolve, join, relative, dirname, basename } from 'node:path';
50
+
51
+ const cwd = process.cwd();
52
+ const args = process.argv.slice(2);
53
+
54
+ // ── Auto-detect paths ────────────────────────────────────────────────────
55
+ const MANIFEST_CANDIDATES = [
56
+ 'public/build/manifest.json',
57
+ 'public/build/.vite/manifest.json',
58
+ ];
59
+ const CONFIG_CANDIDATES = [
60
+ 'vite.config.js',
61
+ 'vite.config.mjs',
62
+ 'vite.config.ts',
63
+ ];
64
+
65
+ const manifestPath = args[0]
66
+ ? resolve(cwd, args[0])
67
+ : MANIFEST_CANDIDATES.map((p) => resolve(cwd, p)).find(existsSync);
68
+
69
+ const configPath = args[1]
70
+ ? resolve(cwd, args[1])
71
+ : CONFIG_CANDIDATES.map((p) => resolve(cwd, p)).find(existsSync);
72
+
73
+ if (!manifestPath) {
74
+ console.error(
75
+ '[check-vite-manifest] No manifest.json found. ' +
76
+ 'Run `npm run build` first, then re-run this check.',
77
+ );
78
+ process.exit(0); // Skip silently if no build artifact yet.
79
+ }
80
+
81
+ if (!configPath) {
82
+ console.error(
83
+ '[check-vite-manifest] No vite.config.{js,mjs,ts} found. Skipping.',
84
+ );
85
+ process.exit(0);
86
+ }
87
+
88
+ // ── Load manifest ────────────────────────────────────────────────────────
89
+ let manifest;
90
+ try {
91
+ manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
92
+ } catch (e) {
93
+ console.error(
94
+ `[check-vite-manifest] Could not parse ${relative(cwd, manifestPath)}: ${e.message}`,
95
+ );
96
+ process.exit(3);
97
+ }
98
+
99
+ // ── Load vite.config ─────────────────────────────────────────────────────
100
+ let configSrc;
101
+ try {
102
+ configSrc = await readFile(configPath, 'utf8');
103
+ } catch (e) {
104
+ console.error(`[check-vite-manifest] Could not read ${configPath}: ${e.message}`);
105
+ process.exit(3);
106
+ }
107
+
108
+ // ── Extract laravel({ input: [...] }) ────────────────────────────────────
109
+ // Tolerant regex: matches `laravel({ ... input: [ '...', "..." ] ... })`
110
+ // across multiple lines. Also catches the helper form
111
+ // `laravel(['resources/css/app.css', 'resources/js/app.jsx'])`.
112
+ function extractLaravelInputs(src) {
113
+ const inputs = new Set();
114
+
115
+ // Form A: laravel({ input: [...] })
116
+ const formA = /laravel\s*\(\s*\{[\s\S]*?input\s*:\s*\[([\s\S]*?)\][\s\S]*?\}\s*\)/g;
117
+ for (const m of src.matchAll(formA)) {
118
+ const arr = m[1];
119
+ for (const sm of arr.matchAll(/['"`]([^'"`]+)['"`]/g)) inputs.add(sm[1]);
120
+ }
121
+
122
+ // Form B: laravel([ ... ]) (shorthand)
123
+ const formB = /laravel\s*\(\s*\[([\s\S]*?)\]\s*\)/g;
124
+ for (const m of src.matchAll(formB)) {
125
+ const arr = m[1];
126
+ for (const sm of arr.matchAll(/['"`]([^'"`]+)['"`]/g)) inputs.add(sm[1]);
127
+ }
128
+
129
+ return [...inputs];
130
+ }
131
+
132
+ // ── Extract import.meta.glob patterns from JS sources ────────────────────
133
+ // We scan the bootstrap entries listed in laravel.input plus any obvious
134
+ // Inertia files (app.jsx, app.tsx, ssr.jsx, ssr.tsx, bootstrap.js) under
135
+ // resources/js/.
136
+ async function findInertiaGlobs(laravelInputs) {
137
+ const candidates = new Set();
138
+ for (const input of laravelInputs) {
139
+ if (/\.(jsx?|tsx?)$/.test(input)) candidates.add(input);
140
+ }
141
+ for (const f of ['app.jsx', 'app.tsx', 'ssr.jsx', 'ssr.tsx', 'bootstrap.js']) {
142
+ const p = `resources/js/${f}`;
143
+ if (existsSync(resolve(cwd, p))) candidates.add(p);
144
+ }
145
+
146
+ const patterns = [];
147
+ for (const rel of candidates) {
148
+ const abs = resolve(cwd, rel);
149
+ if (!existsSync(abs)) continue;
150
+ const src = await readFile(abs, 'utf8');
151
+
152
+ // resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx'))
153
+ // We just want every `import.meta.glob('...')` literal.
154
+ for (const m of src.matchAll(
155
+ /import\.meta\.glob\s*\(\s*\[?\s*['"`]([^'"`]+)['"`]/g,
156
+ )) {
157
+ patterns.push({ file: rel, pattern: m[1] });
158
+ }
159
+ // Multi-pattern form: import.meta.glob(['./Pages/**/*.jsx', './Other/**/*.jsx'])
160
+ const multi = /import\.meta\.glob\s*\(\s*\[([\s\S]*?)\]/g;
161
+ for (const m of src.matchAll(multi)) {
162
+ for (const sm of m[1].matchAll(/['"`]([^'"`]+)['"`]/g)) {
163
+ patterns.push({ file: rel, pattern: sm[1] });
164
+ }
165
+ }
166
+ }
167
+ return patterns;
168
+ }
169
+
170
+ // Convert a `import.meta.glob` pattern (relative to its host file) into an
171
+ // absolute prefix + suffix matcher. Globs supported: `**`, `*`, and explicit
172
+ // `{jsx,tsx,vue,svelte}` extension brace groups.
173
+ function compileGlob(hostFile, pattern) {
174
+ const hostDir = dirname(resolve(cwd, hostFile));
175
+ // Resolve `./` and `../` segments against the host directory.
176
+ let absPattern = resolve(hostDir, pattern);
177
+ absPattern = absPattern.replace(/\\/g, '/'); // Windows safety
178
+
179
+ // Build a regex from the glob.
180
+ // Step 1: expand brace groups `{a,b,c}`.
181
+ const expandBraces = (str) => {
182
+ const m = str.match(/\{([^{}]+)\}/);
183
+ if (!m) return [str];
184
+ const opts = m[1].split(',');
185
+ const out = [];
186
+ for (const o of opts) {
187
+ out.push(...expandBraces(str.slice(0, m.index) + o + str.slice(m.index + m[0].length)));
188
+ }
189
+ return out;
190
+ };
191
+
192
+ // Step 2: convert each expansion into a regex.
193
+ const regexes = expandBraces(absPattern).map((expanded) => {
194
+ const reSrc = expanded
195
+ .replace(/[.+^$()|[\]\\]/g, '\\$&')
196
+ .replace(/\*\*/g, '__GLOBSTAR__')
197
+ .replace(/\*/g, '[^/]*')
198
+ .replace(/__GLOBSTAR__/g, '.*');
199
+ return new RegExp(`^${reSrc}$`);
200
+ });
201
+
202
+ return { pattern, hostFile, regexes };
203
+ }
204
+
205
+ function globMatches(compiled, absPath) {
206
+ const normalized = absPath.replace(/\\/g, '/');
207
+ return compiled.regexes.some((re) => re.test(normalized));
208
+ }
209
+
210
+ // ── Run validation ───────────────────────────────────────────────────────
211
+ const laravelInputs = extractLaravelInputs(configSrc);
212
+ if (laravelInputs.length === 0) {
213
+ console.error(
214
+ '[check-vite-manifest] Could not find laravel({ input: [...] }) in ' +
215
+ relative(cwd, configPath) +
216
+ '. Skipping (is this a Laravel + Vite project?).',
217
+ );
218
+ process.exit(0);
219
+ }
220
+
221
+ const errors = [];
222
+ const warnings = [];
223
+
224
+ // R1. Every laravel.input MUST be in the manifest as isEntry.
225
+ for (const input of laravelInputs) {
226
+ const entry = manifest[input];
227
+ if (!entry) {
228
+ errors.push({
229
+ rule: 'R1',
230
+ msg: `Input "${input}" declared in laravel.input but absent from manifest. Did the build fail?`,
231
+ });
232
+ continue;
233
+ }
234
+ if (!entry.isEntry) {
235
+ errors.push({
236
+ rule: 'R1',
237
+ msg: `Input "${input}" present in manifest but NOT marked isEntry. Check laravel-vite-plugin version.`,
238
+ });
239
+ }
240
+ }
241
+
242
+ // R2 + R3. Cross-reference laravel.input against glob patterns.
243
+ const globs = await findInertiaGlobs(laravelInputs);
244
+ if (globs.length > 0) {
245
+ const compiledGlobs = globs.map((g) => compileGlob(g.file, g.pattern));
246
+
247
+ for (const input of laravelInputs) {
248
+ if (!/\.(jsx?|tsx?)$/.test(input)) continue; // skip CSS, etc.
249
+ const absInput = resolve(cwd, input);
250
+ for (const cg of compiledGlobs) {
251
+ if (globMatches(cg, absInput)) {
252
+ errors.push({
253
+ rule: 'R2',
254
+ msg:
255
+ `Collision: "${input}" is BOTH in laravel.input[] AND matched by ` +
256
+ `import.meta.glob("${cg.pattern}") in ${cg.hostFile}. ` +
257
+ `Rollup/Rolldown will silently collapse the manualChunks group ` +
258
+ `containing this module, leaving the glob resolve-map pointing ` +
259
+ `siblings at the wrong chunk hash. Either remove from ` +
260
+ `laravel.input[], exclude from the glob, or add early ` +
261
+ `\`return undefined\` for this module in manualChunks.`,
262
+ });
263
+ }
264
+ }
265
+ }
266
+ }
267
+
268
+ // R3. Pages/ files marked as isEntry that are NOT in laravel.input.
269
+ // These mean someone added an entry chunk indirectly (e.g. dynamic import
270
+ // promoted to entry by chunking heuristics) — worth flagging.
271
+ const declaredInputSet = new Set(laravelInputs);
272
+ for (const [key, entry] of Object.entries(manifest)) {
273
+ if (!entry.isEntry) continue;
274
+ if (declaredInputSet.has(key)) continue;
275
+ if (key.includes('resources/js/Pages/')) {
276
+ warnings.push({
277
+ rule: 'R3',
278
+ msg:
279
+ `Suspicious entry chunk: "${key}" is under Pages/ and marked ` +
280
+ `isEntry=true but NOT declared in laravel.input[]. This usually ` +
281
+ `means the bundler promoted it to entry to break a circular import ` +
282
+ `or because manualChunks excluded it. Verify the resolve-map of ` +
283
+ `import.meta.glob still points other pages at THIS chunk's siblings, ` +
284
+ `not at this chunk.`,
285
+ });
286
+ }
287
+ }
288
+
289
+ // ── Report ───────────────────────────────────────────────────────────────
290
+ const tag = '[check-vite-manifest]';
291
+
292
+ if (warnings.length > 0) {
293
+ for (const w of warnings) console.warn(`${tag} WARN ${w.rule}: ${w.msg}`);
294
+ }
295
+
296
+ if (errors.length === 0) {
297
+ console.log(
298
+ `${tag} OK ${laravelInputs.length} input(s), ${globs.length} glob(s), ` +
299
+ `${Object.keys(manifest).length} manifest entries — no collisions.`,
300
+ );
301
+ process.exit(0);
302
+ }
303
+
304
+ for (const e of errors) console.error(`${tag} FAIL ${e.rule}: ${e.msg}`);
305
+ console.error(
306
+ `\n${tag} Manifest validation failed: ${errors.length} error(s). ` +
307
+ `See "Vite Build Gotchas" in the inertia-react skill for the fix pattern.`,
308
+ );
309
+ process.exit(errors.some((e) => e.rule === 'R1') ? 2 : 1);
@@ -1,10 +1,13 @@
1
1
  ---
2
2
  name: inertia-react
3
- version: 2.0.0
3
+ version: 2.1.0
4
4
  description: LEGACY skill — Inertia.js + React with Laravel-rendered pages. Use
5
5
  ONLY in pre-existing projects already built on Inertia. For NEW projects use
6
6
  `laravel-api-architecture` + `axios-laravel-api` + `react-api-standards`
7
- (API-first React SPA, no controller-rendered pages).
7
+ (API-first React SPA, no controller-rendered pages). v2.1.0 adds the "Vite
8
+ Build Gotchas" section covering the manualChunks × entry-chunk ×
9
+ resolvePageComponent glob collision (silent wrong-component render
10
+ post-mortem 2026-05).
8
11
  ---
9
12
 
10
13
  # Inertia.js + React — Laravel Frontend (LEGACY)
@@ -207,6 +210,124 @@ export interface PaginatedData<T> {
207
210
  }
208
211
  ```
209
212
 
213
+ ## Vite Build Gotchas (Inertia-specific)
214
+
215
+ > **Production post-mortem 2026-05.** A `vite.config.js` "perf" change adding
216
+ > `manualChunks` to group `Pages/Auth/*` produced a silent wrong-component
217
+ > render: `Inertia::render('Auth/Login', ...)` returned HTTP 200 OK but the
218
+ > browser rendered the error page. Laravel logs were empty. Bug lived
219
+ > entirely in the bundle graph.
220
+
221
+ ### The three-way collision
222
+
223
+ ```
224
+ laravel-vite-plugin ┐ laravel({ input: [...HttpErrorPage] })
225
+ │ → module becomes an ENTRY chunk
226
+ │ Rollup/Rolldown ALWAYS prioritizes entries.
227
+
228
+ @inertiajs/react ┐ resolvePageComponent(..., import.meta.glob(
229
+ │ './Pages/**/*.jsx'))
230
+ │ → builds a STATIC resolve-map at build time
231
+ │ pointing each Page path to its chunk hash.
232
+
233
+ build.rollupOptions ┐ manualChunks(id) { if (Auth) return 'pages-auth' }
234
+ │ → ADVISORY ONLY. Returning a group for a module
235
+ │ that's already an entry has NO EFFECT and
236
+ │ emits NO WARNING.
237
+ ```
238
+
239
+ When the same module (e.g. `HttpErrorPage.jsx`) is BOTH:
240
+
241
+ 1. listed in `laravel.input[]` (typical: error pages referenced directly via
242
+ `@vite()` in `resources/views/app.blade.php` or a layout), AND
243
+ 2. caught by a `manualChunks` rule (e.g. `pages-auth`),
244
+
245
+ …Rollup/Rolldown creates a **standalone entry chunk** with only that one
246
+ module. The `pages-auth` group collapses into that entry. The
247
+ `import.meta.glob` resolve-map points **every sibling page**
248
+ (`Login`, `Register`, `ForgotPassword`, …) at the same chunk hash. The
249
+ siblings' source is discarded.
250
+
251
+ Symptom: server sends `component: 'Auth/Login'`, browser loads the chunk,
252
+ chunk's `default` export is `HttpErrorPage`, error page renders. Server 100%
253
+ correct; bundle ships the wrong default export.
254
+
255
+ ### Rule 1 — Never duplicate a module between `laravel.input` and the `Pages/**` glob
256
+
257
+ Either exclude the entry page from the Inertia glob, OR short-circuit
258
+ `manualChunks` BEFORE any grouping rule to preserve the entry's identity.
259
+ Preferred pattern (no change to Inertia bootstrap):
260
+
261
+ ```js
262
+ // vite.config.js
263
+ build: {
264
+ rollupOptions: {
265
+ output: {
266
+ manualChunks(id) {
267
+ if (!id.includes('/resources/js/Pages/')) return;
268
+
269
+ // Entry chunks referenced directly by @vite() in blade MUST
270
+ // return undefined here — BEFORE any grouping rule. Otherwise
271
+ // the manualChunks group is collapsed into the entry and the
272
+ // import.meta.glob resolve-map points siblings at the wrong
273
+ // chunk hash. Production post-mortem 2026-05.
274
+ if (id.includes('/Pages/OtherPages/HttpErrorPage')) return;
275
+
276
+ if (id.includes('/Pages/Auth/') || id.includes('/Pages/OtherPages/')) {
277
+ return 'pages-auth';
278
+ }
279
+ if (id.includes('/Pages/Dashboard/')) {
280
+ return 'pages-dashboard';
281
+ }
282
+ },
283
+ },
284
+ },
285
+ },
286
+ ```
287
+
288
+ ### Rule 2 — `manualChunks` is advisory; entries always win
289
+
290
+ There is no warning when Rollup/Rolldown ignores a `manualChunks` return value
291
+ for an entry module. Validation MUST be done out-of-band on `manifest.json`
292
+ after every build.
293
+
294
+ ### Rule 3 — Validate `public/build/manifest.json` after every `vite build`
295
+
296
+ `start-vibing-stacks` ships `scripts/check-vite-manifest.mjs` (wired as the
297
+ `ViteManifest` quality gate at order 5):
298
+
299
+ ```bash
300
+ node scripts/check-vite-manifest.mjs public/build/manifest.json vite.config.js
301
+ ```
302
+
303
+ The script cross-references `laravel.input[]` against `Pages/**` glob patterns
304
+ and fails (non-zero exit) on any collision.
305
+
306
+ ### Rule 4 — Smoke-test after any `vite.config.js` change touching `build`
307
+
308
+ For one critical route per page group:
309
+
310
+ 1. DevTools → Network → click the Inertia XHR → read `component:` in the JSON.
311
+ 2. Click the JS asset request that follows → open the resolved chunk URL.
312
+ 3. Search for `default:` / `export{ ... as default}` in that chunk. The
313
+ exported component name MUST match the server's `component:`.
314
+
315
+ If they don't match, revert the last `vite.config.js` change before debugging
316
+ anything else.
317
+
318
+ ### Why this class of bug is so misleading
319
+
320
+ | Layer | What it looks like | Why it misleads |
321
+ |---|---|---|
322
+ | Laravel logs | Empty | Backend is genuinely correct |
323
+ | `manifest.json` | Valid, every input has an entry | Manifest doesn't enforce uniqueness across groups |
324
+ | Browser network | 200 OK on every request | The wrong JS arrives successfully |
325
+ | Console | Clean | The rendered component is valid React |
326
+
327
+ Triage rule: **wrong-component render with HTTP 200 and empty server logs =
328
+ bug is in the bundle, not the server.** See `debugging-patterns §Bundle, not
329
+ Backend`.
330
+
210
331
  ## FORBIDDEN
211
332
 
212
333
  1. **API routes for Inertia pages** — use `Inertia::render()` in controllers
@@ -214,3 +335,6 @@ export interface PaginatedData<T> {
214
335
  3. **Fetching data in useEffect** — pass as props from controller
215
336
  4. **Duplicating validation** — validate in FormRequest, show errors from `useForm`
216
337
  5. **`any` types for page props** — always type with `interface Props extends PageProps`
338
+ 6. **Same module in `laravel.input[]` and `Pages/**` glob** — Rollup collapses the manual chunk group into the entry; resolve-map silently points siblings at the wrong chunk hash (wrong-component render with HTTP 200)
339
+ 7. **`manualChunks` grouping pages without running `check-vite-manifest.mjs`** — grouping is advisory and silently ignored for entry chunks
340
+ 8. **Trusting empty Laravel logs as "no bug"** — server can be 100% correct while the bundle ships the wrong `default` export
@@ -19,7 +19,8 @@
19
19
  { "name": "PHPStan", "command": "vendor/bin/phpstan analyse --level=6", "required": true, "order": 1 },
20
20
  { "name": "PHPUnit", "command": "vendor/bin/phpunit", "required": true, "order": 2 },
21
21
  { "name": "TypeCheck", "command": "npx tsc --noEmit", "required": true, "order": 3 },
22
- { "name": "Lint", "command": "npx eslint resources/js/", "required": false, "order": 4 }
22
+ { "name": "Lint", "command": "npx eslint resources/js/", "required": false, "order": 4 },
23
+ { "name": "ViteManifest", "command": "node scripts/check-vite-manifest.mjs", "required": false, "order": 5 }
23
24
  ],
24
25
  "frameworks": [
25
26
  {
@@ -310,6 +310,22 @@ const stripePublishable = import.meta.env.VITE_STRIPE_KEY; // pk_...
310
310
  | `useEffect` to derive state | Anti-pattern — use `useMemo` |
311
311
  | Skipping skeleton/empty/error states | Bad UX — all three are mandatory per page |
312
312
 
313
+ ### Vite Build (CRITICAL — silent bug class)
314
+
315
+ > **Production post-mortem 2026-05.** A bad `manualChunks` rule can produce
316
+ > silent wrong-component renders (HTTP 200, empty Laravel logs, browser
317
+ > shows the error page when server asked for `Auth/Login`). Bug lives in the
318
+ > bundle graph, not the server. See `inertia-react §Vite Build Gotchas` and
319
+ > `debugging-patterns §Bundle, not Backend`.
320
+
321
+ | Action | Reason |
322
+ |--------|--------|
323
+ | Same module in `laravel.input[]` and `Pages/**` glob | Rollup/Rolldown silently collapses the manualChunks group into the entry chunk; `import.meta.glob` resolve-map points siblings at the wrong hash |
324
+ | `manualChunks` grouping pages without short-circuit for entry pages | `manualChunks` is advisory — entries always win, with no warning. Add early `return undefined` for any page also listed in `laravel.input[]` |
325
+ | Skipping `node scripts/check-vite-manifest.mjs` after `vite build` | Bundler emits no warning on collision; manual validation is the only signal |
326
+ | Debugging Laravel/server when HTTP 200 + empty logs + wrong content | Triage as "Bundle, not Backend" — start from the JS chunk's `default` export, not the controller |
327
+ | Adding new `@vite('resources/js/Pages/...')` direct reference in blade without auditing `vite.config.js` | Promoting a page to entry chunk while it's still in the Inertia glob is the exact collision shape |
328
+
313
329
  ## UI/UX Design Intelligence
314
330
 
315
331
  > When the project has a frontend, the **UI/UX Pro Max** skill is auto-installed. It provides 67 UI styles, 161 color palettes, 57 font pairings, and 161 industry-specific reasoning rules. It activates automatically for any UI/UX task.