Skip to content

fix: resolve the solid-js server build for webworker SSR targets - #442

Open
lxsmnsyc wants to merge 2 commits into
mainfrom
fix/153-ssr-webworker-conditions-main
Open

lxsmnsyc wants to merge 2 commits into
mainfrom
fix/153-ssr-webworker-conditions-main

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

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

An SSR build with ssr.target: 'webworker' now bundles the server build of solid-js. Before, it bundled the browser build, so isServer was false and renderToString threw not supported in the browser.

Cause

  • With ssr.target: 'webworker', Vite gives the SSR environment the client resolve conditions.
  • Since Vite 6, the top-level resolve.conditions no longer reaches the SSR environment.
  • solid-js puts its server build under the worker condition.

Changes

  • Vite 6 and later: the plugin adds worker to the SSR environment's conditions.
  • Vite 4 and 5: the plugin sets ssr.resolve.conditions, keeping the top-level conditions that option replaces.
  • Vite 3 has no ssr.resolve.conditions option and is not covered.

Testing

  • Reproduced on Vite 5 to 8 with no user conditions, and on Vite 6 to 8 with the config from the issue.
  • With the fix, Vite 4, 5, 6, 7 and 8 bundle the server build with all three test configs.
  • Added a regression test that fails without the fix.
  • vitest run and tsc --noEmit pass.

Note on the first commit

main had no unit tests. The first commit adds the same Vitest setup that next uses: a root vitest.config.ts, a test:unit script, and a step in the Vitest workflow. The other main fix PRs from this batch (#112, #153, #206, #130, #141) share this exact commit, so they do not conflict on it.

🤖 Generated with Claude Code

lxsmnsyc and others added 2 commits October 19, 2026 11:34
- Add a root vitest config and a test:unit script, matching the next branch.
- Run the unit tests in the vitest workflow.
- Exclude test files from the declaration build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- With ssr.target set to webworker, the SSR build resolved the browser build of solid-js and renderToString threw.
- Vite 6+: add the worker export condition to the ssr environment.
- Vite 4 and 5: set ssr.resolve.conditions with the worker condition, keeping the top-level conditions it replaces.
- Add build tests for the webworker and node targets.

Fixes #153

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: 9c17655

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

This PR includes changesets to release 1 package
Name Type
vite-plugin-solid 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/vite-plugin-solid@442

commit: 9c17655

@ryansolid ryansolid added the 1.x label Oct 21, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite does not load proper build (server) on ssr webworker build

2 participants