Commit 185d03a
fix(ssg): give the resolved config the router key its pages read
`main` has not typechecked since 566dfde, and four releases went out on it —
0.2.259 through 0.2.263.
That commit fixed the SSG's router forwarding by calling
`injectRouterScript(html, { router: options.router })` inside `renderPage`, and
took an `any` cast off `SSGConfig.router` so the field had a real type. Both
halves were right; the value was not there. `renderPage` is called with the
`cfg` built in `generateStaticSite`, so its `options.router` is `cfg.router` —
and `cfg` never had a `router` key. Every page read `undefined`, no
`__stxRouterConfig` was emitted, and a project that set `container` or
`prefetch` still got the client's built-in defaults. The fix was inert.
Nothing caught it except the type. `Required<SSGConfig>` turned the missing key
into TS2741, which is the compiler reporting precisely the bug that commit set
out to fix — and it was left unresolved, so the signal became noise on every
run since.
So populate the key. It reads the loaded config rather than `buildConfig`
because `router` is a top-level key of `stx.config.ts`, like `partialsDir`
beside it, and an explicit call option wins, like every other key in the
object.
The tests read the built HTML. An inert fix passes anything that asserts on the
call site, which is how this shipped in the first place, so these run
`generateStaticSite` against a project that declares a container and check what
comes out — including flags set to `false`, the case a truthy forward drops
while looking correct. Verified to fail against the unfixed file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 9d70685 commit 185d03a
2 files changed
Lines changed: 101 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1092 | 1104 | | |
1093 | 1105 | | |
1094 | 1106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments