Commit 170436f
fix: disable HMR for SSR transforms to prevent ERR_LOAD_URL (#110)
* fix: disable HMR for SSR transforms to prevent ERR_LOAD_URL
When Nitro or other SSR frameworks process server-side code through
Vite's module runner, the HMR initialization code would dynamically
import @ng/component virtual modules that are only served via HTTP
middleware, causing ERR_LOAD_URL failures.
- Check options.ssr in transform hook and disable HMR for SSR bundles
- Add resolveId/load hooks for @ng/component as safety net in SSR context
- Skip file watcher registration for SSR transforms
This matches Angular's official behavior where _enableHmr is only set
for browser bundles, never for SSR bundles.
- Close #109
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: keep SSR resource watchers for cache invalidation
The fs.watch callback serves dual purpose: (1) invalidating
resourceCache on file change, and (2) sending HMR WebSocket events.
The HMR part is already independently gated by componentIds, which
are only populated for client transforms. Skipping watcher
registration for SSR would leave resourceCache stale when external
templates/styles change.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b43c439 commit 170436f
File tree
2 files changed
+121
-3
lines changed- napi/angular-compiler
- test
- vite-plugin
2 files changed
+121
-3
lines changed| 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 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
229 | 244 | | |
230 | 245 | | |
231 | 246 | | |
| |||
426 | 441 | | |
427 | 442 | | |
428 | 443 | | |
429 | | - | |
| 444 | + | |
430 | 445 | | |
431 | 446 | | |
432 | 447 | | |
| |||
450 | 465 | | |
451 | 466 | | |
452 | 467 | | |
453 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
454 | 476 | | |
455 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
456 | 482 | | |
457 | 483 | | |
458 | 484 | | |
| |||
470 | 496 | | |
471 | 497 | | |
472 | 498 | | |
473 | | - | |
| 499 | + | |
474 | 500 | | |
475 | 501 | | |
476 | 502 | | |
| |||
0 commit comments