solidjs / solidjs/solid-vite-plugin
@solidjs/testing-library resolves @solidjs/web to the server build (isServer true) in jsdom tests under a multi-project vitest setup
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 520
- Forks
- 70
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 39
Description
Environment
@solidjs/vite-plugin3.0.0-next.44vitest5.0.1, multi-project (projects),pool: threads,isolate: falsesolid-js/@solidjs/web2.0.0-rc.9@solidjs/testing-library1.0.0-beta.3
Reproduction
A vitest config with two projects, one jsdom ("client") and one node ("server"):
test: {
projects: [
{ test: { name: "client", environment: "jsdom", include: ["src/**/*.test.tsx"] } },
{ test: { name: "server", environment: "node", include: ["src/server/**/*.test.ts"] } },
],
}
In a test file, import { isServer } from "@solidjs/web" is false (correct browser build). But inside @solidjs/testing-library's render, @solidjs/web is the server build (isServer === true), so render/hydrate behave incorrectly.
Root cause
In the client/jsdom test posture the plugin injects browser into resolve.conditions (fixing inlined modules) but leaves @solidjs/web and @solidjs/testing-library externalized — and explicitly externalizes solid-js via test.server.deps.external: [/solid-js/]. Externalized modules are executed natively by Node, whose resolution conditions are ['node', 'import', 'default'] (no browser). So @solidjs/testing-library's own import { render, hydrate } from "@solidjs/web" resolves the node export (dist/server.js).
The plugin already handles the inverse case for the node/server posture by inlining /solid-js/ + /@solidjs[+/]web/, but the client posture gets no equivalent treatment.
Workaround
Inline the runtime packages so their imports resolve through Vite's browser condition:
test: {
server: {
deps: {
inline: ["solid-js", "@solidjs/web", "@solidjs/testing-library"],
},
},
}
(deps.inline takes precedence over deps.external.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the plugin's dependency handling for the node/server posture and compare it with the client/jsdom path described in the issue. Reproduce the multi-project Vitest setup, then verify that render and hydrate resolve the browser build without requiring the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript, vite
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100