Commit fd9e463
fix: handle CJS in SSR dev mode and fix React compat aliasing
- Add lightweight CJS shim in deno.ts load hook for dev mode: wraps
CJS files in node_modules with module/exports/require so Vite's
SSR module runner can evaluate them. Only ~30 lines vs the old
960-line Babel CJS transform. Only runs in dev mode — build mode
uses Rollup's @rollup/plugin-commonjs natively.
- Restore ssr.noExternal: true so resolve.alias (react -> preact/compat)
is applied consistently in SSR. Without it, Node.js require() bypasses
aliases and loads real react@19.1.1.
- Apply resolve.alias in deno.ts resolveId before @deno/loader runs,
so aliased specifiers (react, react-dom) resolve to preact/compat
through the Deno resolution pipeline.
- Remove environment-level noExternal (was duplicated).
Test results: 35/36 dev tests pass, 31/31 build tests pass.
The 1 failing test (remote island) is pre-existing on main.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent e4c4334 commit fd9e463
2 files changed
Lines changed: 48 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
115 | 122 | | |
116 | 123 | | |
117 | 124 | | |
| |||
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
187 | 228 | | |
188 | 229 | | |
189 | 230 | | |
| |||
0 commit comments