Using vite-plugin-solid with vitest workspaces prevents solid-js from resolving correctly
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript, vite
- Domain
- build-system, testing
Research direction
Start with the linked StackBlitz reproduction and run npm run test-all, then compare it with npm run test-fe-only and npm run test-all-no-plugin. Inspect how vite-plugin-solid interacts with Vitest workspaces and the solid-js resolution shown in node_modules/solid-js/store/dist/dev.js. Done means the workspace test calling createStore no longer throws while the plugin remains enabled.
Written by the indexing model from the issue text.
Description
Description
Vitest has a workspaces feature, where vitest can be made aware of different sub-projects, and run the tests for each of these workspaces (based on their individual configuration) together.
However, when using Vitest workspaces and vite-plugin-solid, the solid-js resolution system fails to work properly, and functions like createStore() throw errors.
Reproduction
https://stackblitz.com/edit/solidjs-templates-4usktg?file=README.md&view=editor
The problem can be reproduced by running npm run test-all in the console. This runs a test that just calls createStore.
Running npm run test-fe-only runs vitest in the frontend/ package, which bypasses Vitest's workspaces system, everything works again.
Running npm run test-all-no-plugin runs vitest the same as in test-all, but with the vite-plugin-solid plugin disabled. Again, this works as expected.
Error/Investigation
The error returned is:
TypeError: Cannot read properties of undefined (reading 'registerGraph')
❯ Module.createStore node_modules/solid-js/store/dist/dev.js:213:9
❯ packages/frontend/src/test.spec.ts:6:36
This is because in dev-mode, the createStore tries to access the DEV object exported by solid-js. This DEV object is only available if solid-js is running in dev mode (in production, a different file is used which sets DEV to undefined).
However, for some reason, when Vite/NodeJS/Vitest/? tries to resolve the import solid-js from node_modules/solid-js/store/dist/dev.js, it instead imports the production version of solid-js, which obviously doesn't have the correct exported DEV object, and so an error is thrown.
I'm creating this issue here, because the error only occurs if vite-plugin-solid is installed, but I'm not entirely sure what this plugin is doing that makes things behave weirdly here. There isn't any JSX to process, so I would have through the plugin is essentially a no-op.
Thanks for any help!
- Dominant language
- TypeScript
- Stars
- 520
- Forks
- 70
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 39
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.
More from solidjs/solid-vite-plugin
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solidjs/solid-vite-plugin#205 · 1 comment · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
solidjs/solid-vite-plugin#369 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
solidjs/solid-vite-plugin#328 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
solidjs/solid-vite-plugin#308 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
solidjs/solid-vite-plugin#262 · 2 comments ·
All issues in solidjs/solid-vite-plugin
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·