mswjs / msw-storybook-addon

Mock API requests in Storybook with Mock Service Worker.
https://msw-sb.vercel.app
MIT License
408 stars 39 forks source link

msw@2.4.1 breaks due to `graphql` peer dependency #162

Closed tmeindle closed 2 weeks ago

tmeindle commented 1 month ago

When updating my msw to versions greater than 2.4.0 msw-storybook-addon stops functioning in portable stories rendered in tests in vitest (and react swc plugin).

Using latest versions of storybook, vitest, and storybook.

Msw 2.4.1 added a peer dependency on graphql in a patch version update. Adding a peer dependency is usually introduces breaking changes.

kettanaito commented 2 weeks ago

Hi. The change that added graphql as a optional peer dependency has been reverted. Update msw to get the changes.

Introducing optional peer dependencies is not a breaking change—that's the whole point of them being optional. Sadly, there isn't a proper protocol to achieve optional peer dependencies in JavaScript as of now, especially across multiple module formats.

tmeindle commented 2 weeks ago

Hello Atyem,

I will start by saying that msw and msw-storybook-addon are awesome invaluable tools for developing, testing, and demoing! I thank you and all contributors.

However, I have to politely disagree with your thinking above. In my case adding this optional peerDependency was a breaking change I had to track down why stuff broke and stopped working and then actually install graphql to get stuff working again. This is the only reason I made an issue. Reverting the change would of been another breaking change major update because people need to be able to adjust their installed dependencies when they are utilizing lax semver such as ^ and ~ and run a npm update. Luckily I lock all my versions and knew exactly where the issue arose because I only updated the two package versions manually.

please see:

https://github.com/semver/semver/issues/502#issuecomment-466501843

https://github.com/semver/semver/issues/502#issuecomment-2215443827

and this article which the above is a reply to: https://8hob.io/posts/semantic-versioning-npm-packages-after-dependency-update/#versioning-after-updating-a-peer-dependency

Thanks again for all the awesome tools, Tim