tajo / ladle

🥄 Develop, test and document your React story components faster.
https://www.ladle.dev
MIT License
2.63k stars 93 forks source link

Should the msw implementation be created as an independent plugin? #544

Closed Scott-Fischer closed 11 months ago

Scott-Fischer commented 11 months ago

Is your feature request related to a problem? Please describe. I love both ladle and msw but the experience of trying to integrate msw v2 with anything but vitest has been a nightmare for most of us. The msw library maintainers made a pretty bold stance on Jest when they released v2.

As a result, a lot of teams are staying on msw v1 until a more robust solution is created for maintaining compatibility between jest/jsdom and msw.

The problem I'm now facing is that even if I am not using the msw implementation with ladle, upgrading @ladle/react requires updating msw due to the peer dependency. That means I'm now basically locked into an older version of ladle.

Describe the solution you'd like A separate package to represent the msw integration in ladle so that users can opt into it rather than requiring a peer dependency on the main package.

tajo commented 11 months ago

upgrading @ladle/react requires updating msw due to the peer dependency

msw is a direct dependency of Ladle and there are no other packages/peerDeps? I don't understand why you couldn't install msw@1 next to Ladle?

Btw, we are also using Jest + MSW2. It's not that difficult to setup, just need to make sure that you give back fetch and other native APIs that Jest is hiding.

the msw implementation be created as an independent plugin

I am really trying to avoid that. The setup is not straightforward and supporting both MSW1+2 would add a lot of maintenance burden as well.

Scott-Fischer commented 11 months ago

upgrading @ladle/react requires updating msw due to the peer dependency

msw is a direct dependency of Ladle and there are no other packages/peerDeps? I don't understand why you couldn't install msw@1 next to Ladle?

You're right, I was able to do this eventually, it just wasnt quite as intuitive as I thought. When first upgrading my version of ladle, it was automatically updating msw and generating a new mockServiceWorker.js file. If anyone else ends up in this situation, you can resolve it by uninstalling msw after upgrading ladle then reinstalling msw at the version of v1 that you want.

Btw, we are also using Jest + MSW2. It's not that difficult to setup, just need to make sure that you give back fetch and other native APIs that Jest is hiding.

I took some time and worked though this as well and was eventually able to restore functionality in jest with v2.

Thanks for the advice, I'll go ahead and close this issue.