Skip to content

fix: compile server transforms with SSR output when ssr is off - #447

Merged
ryansolid merged 1 commit into
nextfrom
fix/64-ssr-codegen-without-ssr-option
Oct 21, 2026
Merged

ryansolid merged 1 commit into
nextfrom
fix/64-ssr-codegen-without-ssr-option

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Fixes #64 on next. The fix for main (1.x) is in a separate PR.

Without ssr: true, modules loaded on the server are now compiled to SSR output. A client-rendered app can now prerender pages with ssrLoadModule. Before, those modules were compiled to DOM output and threw Client-only API called on the server side.

Changes

  • When ssr is off, server transforms use generate: 'ssr' with hydratable: false.
  • Client transforms are unchanged. With ssr: true the behavior is unchanged.
  • No existing option allowed this. solid.generate also applies to the client, and a babel function cannot replace the preset.
  • The ssr option's JSDoc and README entry describe the new behavior.

Behavior change

Anyone who loads modules on the server without ssr: true now gets SSR output instead of DOM output. DOM output could not run on the server, so this should only affect setups that loaded those modules without rendering them.

Testing

  • Added src/ssr-codegen.test.ts. It fails without the fix: the server transform still contains template.
  • pnpm test:unit passes 23/23. The css-matrix, ssr, start-client and start-env example suites pass.
  • The start-ssr suite failed on different browser checks in runs with and without the fix. It uses ssr: true, which this change does not touch.

🤖 Generated with Claude Code

- Without `ssr: true`, modules loaded on the server were compiled to DOM
  output and threw "Client-only API called on the server side".
- Server transforms now use `generate: 'ssr'` with `hydratable: false`, so
  a client-rendered app can prerender pages with `ssrLoadModule`.
- Client transforms are unchanged.

Fixes #64

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7335d3a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/vite-plugin@447

commit: 7335d3a

@ryansolid
ryansolid merged commit 1de7940 into next Oct 21, 2026
6 checks passed
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.

2 participants