Skip to content

fix(vitest): inline the Solid runtime and its consumers in client tests - #433

Merged
ryansolid merged 1 commit into
nextfrom
fix/369-client-test-inline-runtime
Oct 21, 2026
Merged

ryansolid merged 1 commit into
nextfrom
fix/369-client-test-inline-runtime

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

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

In jsdom tests, packages that import @solidjs/web, such as @solidjs/testing-library, now get the browser build under Deno. Before, render threw Client-only API called on the server side.

Cause

  • The client test setup kept solid-js external, along with the packages that use it.
  • External packages are loaded by the host runtime, not by Vite.
  • Deno does not pass Vitest's browser condition to worker threads (pool: 'threads'). Those threads resolved @solidjs/web to the server build.

Changes

  • In the client test setup, the plugin now inlines solid-js, @solidjs/web, and every package that lists either one as a dependency or peer. They resolve through Vite's browser condition.
  • The runtime and the packages that use it are inlined together, so they share one copy of the runtime.
  • A user server.deps.inline list is merged with the plugin's. inline: true and a user external entry for solid-js are left alone.
  • The server test setup is unchanged.

Known limit

  • The plugin finds a package that uses the runtime only if it depends on Solid directly. A package that reaches Solid only through another such package is not inlined, and would still load its own copy of the runtime.

Testing

  • Added examples/start-ssr/src/testing-library.test.tsx. It renders a counter through @solidjs/testing-library and clicks it.
  • Added a runtime-consumers check to node test/run.mjs vitest. It runs the test with a resolve hook that removes browser and adds deno, the same as Deno.
    • Without the fix, it fails with the issue's error.
    • With the fix, it passes with both --pool=forks and --pool=threads.
  • Ran the files from the reporter's repro on Deno 2.9.6 with Vitest 5.0.1.
    • Without the fix, 1 of 3 tests fails with Client-only API called on the server side.
    • With the fix, 3 of 3 pass.
  • pnpm test:unit and tsc --noEmit pass. node test/run.mjs vitest passes 7/7.

🤖 Generated with Claude Code

… test posture

The client posture kept solid-js external, so packages without a `solid`
export condition (such as @solidjs/testing-library) were imported natively
and their own imports were resolved by the host runtime. Node gets the
`browser` condition from vitest's worker --conditions, but Deno resolves
`deno`/`node`, so @solidjs/testing-library loaded the server build of
@solidjs/web and `render` failed with isServer true.

- Inline solid-js, @solidjs/web and the runtime consumers found by the
  vitefu crawl through test.server.deps.inline in the client posture.
- Merge with a user inline list; skip for `inline: true` or a user
  external entry for solid-js.
- Add a start-ssr vitest check that emulates Deno's resolution with a
  Node resolve hook and renders through @solidjs/testing-library.

Refs #369

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: 5c5fd6f

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@433

commit: 5c5fd6f

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