Skip to content

fix(bundler): resolve preact import in SSR bundles#73

Merged
LeeCheneler merged 2 commits into
mainfrom
feat/ssr-bundling-dev-perf
Dec 18, 2025
Merged

fix(bundler): resolve preact import in SSR bundles#73
LeeCheneler merged 2 commits into
mainfrom
feat/ssr-bundling-dev-perf

Conversation

@LeeCheneler
Copy link
Copy Markdown
Contributor

Summary

Fixes SSR bundling error when used from JSR:

Import "preact/jsx-runtime" not a dependency and not in import map

Root cause: The SSR bundle marked preact as external, but when Deno imports the temp bundle file, it can't resolve preact/jsx-runtime because the temp file is outside the project's import map context.

Fix: Bundle preact into the SSR output instead of marking it external. This is fine for SSR since we're just rendering to string and don't need hook state persistence across renders.

Also includes a timing fix for esbuild cleanup to prevent subprocess leaks in tests.

Test plan

  • Local dev server tests pass
  • CI tests pass
  • Manual test with docs project

🤖 Generated with Claude Code

LeeCheneler and others added 2 commits December 18, 2025 23:28
Replaces the subprocess-per-request architecture with esbuild-based SSR
bundling to bypass Deno's module cache. This eliminates:

- Subprocess spawn overhead (50-200ms per request)
- Shiki highlighter reinitialization (200-500ms first render)
- Redundant page scanning (subprocess rescanned on each request)

The new approach:
1. Generates SSR entry code that imports page + layout components
2. Bundles with esbuild (reads fresh files from disk)
3. Writes to unique temp file (bypasses Deno's import cache)
4. Imports and executes to get fresh components
5. Renders in parent process (keeps Shiki warm)

Measured improvement: 600-1200ms -> 150-330ms per page render.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@LeeCheneler LeeCheneler force-pushed the feat/ssr-bundling-dev-perf branch from e69b2bb to 58db679 Compare December 18, 2025 23:29
@LeeCheneler LeeCheneler enabled auto-merge (squash) December 18, 2025 23:29
@LeeCheneler LeeCheneler merged commit b28a268 into main Dec 18, 2025
2 checks passed
@LeeCheneler LeeCheneler deleted the feat/ssr-bundling-dev-perf branch December 18, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant