Skip to content

fix: revert "graphql" as optional peer dependency#2267

Merged
kettanaito merged 1 commit intomainfrom
fix/revert-graphql-optional-peer
Sep 7, 2024
Merged

fix: revert "graphql" as optional peer dependency#2267
kettanaito merged 1 commit intomainfrom
fix/revert-graphql-optional-peer

Conversation

@kettanaito
Copy link
Member

@kettanaito kettanaito commented Sep 7, 2024

Motivation

ESM imports of optional peer dependencies are virtually impossible. You have to opt-out from your bundler treating them as code splitting points because the dependency may not exist, and then as a result, you become in charge of serving that dependency over HTTP + providing an importmap for the browser to understand where to look it up.

This is an insane ask from a developer, and I'm not willing to make it. I was prematurely optimistic about the state of optional peer dependencies, causing the recent release to be a failure. Lessons learned.

Resolving the original issue

The original issue reported in #2185 states that the graphql dependency has to be a peer dependency to prevent duplicate GraphQL versions installed in a single app (MSW installs v16.1, your app has v16.8, and that potentially causes issues).

@kettanaito kettanaito merged commit 7cd39e7 into main Sep 7, 2024
@kettanaito kettanaito deleted the fix/revert-graphql-optional-peer branch September 7, 2024 15:08
@kettanaito
Copy link
Member Author

Released: v2.4.3 🎉

This has been released in v2.4.3!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vitest tests fail with error "Cannot find package 'graphql' imported" in v2.4.0 Module not found: Error: Can't resolve 'graphql'

1 participant