Commit a13cbea
committed
fix(server): bundle superjson into a single ESM file for the browser
Root cause of ALL client-side JS failing:
superjson internally imports \`copy-anything\` which imports \`is-what\` —
both as bare specifiers. The browser's import map only had an entry for
\`superjson\` itself, so the transitive imports failed with:
Uncaught TypeError: Failed to resolve module specifier "copy-anything"
Since webjs/core statically re-exports richFetch which statically
imports superjson, the ENTIRE core module failed to load. No components
registered, no events fired, no interactivity.
Fix: instead of serving superjson's raw dist/ files (which contain bare
imports to its deps), the server now bundles superjson + all transitive
deps into a single self-contained ESM file via esbuild on first request.
Result is cached in-process. 11KB minified, zero bare-specifier leaks.
Import map simplified:
'superjson' → '/__webjs/vendor/superjson.js' (single bundled file)
Removed the old /__webjs/vendor/superjson/* wildcard handler (no longer
needed — one file serves everything).
Also: fixed counter.ts that was broken by a bad sed in the previous
debug commit (stray closing brace).
Verified in production mode (webjs start):
- /__webjs/vendor/superjson.js → 200 (11KB)
- All pages 200
- Counter module 200
- No console errors
- 70/70 framework tests pass1 parent 5ae7d71 commit a13cbea
3 files changed
Lines changed: 49 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 11 | | |
16 | 12 | | |
17 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
311 | 307 | | |
312 | 308 | | |
313 | 309 | | |
| |||
687 | 683 | | |
688 | 684 | | |
689 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
690 | 725 | | |
691 | 726 | | |
692 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | | - | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
0 commit comments