How to import MWS only in dev mode in solid-start
Hi,
I'm creating a #solid-start starter kit and I'm integrating MWS, here's the repo: https://github.com/alveshelio/solid-start-tailwindcss-playwright-template. However I'm having errors when trying to import it in
root.tsx
.
This is how I'm importing it:
However, this is not working. I'm getting this error in the server:
An unhandled error occured: TypeError: vite_ssr_import_1.postHandlers is not iterable (cannot read property undefined)
at eval (/src/mocks/browser/browser.ts:7:39)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async instantiateModule (file:///solidstart/nodemodules/.pnpm/vite@4.2.1@types+node@18.15.11/node_modules/vite/dist/node/chunks/dep-79892de8.js:53996:9)
And in the browser I'm getting this error:
browser.ts:5 Uncaught (in promise) ReferenceError: Cannot access 'postHandlers' before initialization
This thread: https://github.com/mswjs/msw/discussions/712 talks about how to import it in a vite project, but this doesn't work in a solid-start project.
Any help would be greatly appreciated.
Thank you,GitHub
vitejs integration · mswjs msw · Discussion #712
I asked in vitejs github repository on how exclude code for production but unfortunately nobody answered my question. so I ask my question here so hopefully somebody maybe has answer to my question...
0 Replies