solidjs / solidjs/solid-vite-plugin
'Error: No known conditions for "./node" specifier in "msw" package' when using MSW with Vitest
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 520
- Forks
- 70
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 39
Description
Trying to import and use any function from MSW (specifically, msw/node) when running vitest prints this error:
FAIL src/testfile.test.ts [ src/testfile.test.ts ]
Error: No known conditions for "./node" specifier in "msw" package
❯ e node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:21445:25
❯ n node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:21445:646
❯ o node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:21445:1297
❯ resolveExportsOrImports node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28746:20
❯ resolveDeepImport node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28765:31
❯ tryNodeResolve node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28453:20
❯ Context.resolveId node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:28212:28
❯ Object.resolveId node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44276:32
❯ TransformContext.resolve node_modules/.pnpm/vite@4.5.0_@types+node@20.8.10/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:43992:23
This only happens when this plugin is present, removing it seems to fix the issue.
Not sure if this is a bug in the plugin, or a problem on msw's side, or if I'm maybe doing something wrong?
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 import of msw/node in src/testfile.test.ts and reproduce it under Vitest with the plugin enabled. Compare the result after removing the plugin, then trace the reported Vite resolution error to determine whether the plugin or MSW causes it. Done means the import works with the plugin present and the error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100