Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

fix: require react-apollo based on module env #3029

Merged
merged 5 commits into from
May 28, 2019
Merged

fix: require react-apollo based on module env #3029

merged 5 commits into from
May 28, 2019

Conversation

jure
Copy link
Contributor

@jure jure commented May 10, 2019

Attempts to fix #2900 again. #2907 fixed MockedProvider for cases where cjs is used, but not in situations that use ESM, e.g. webpack. This PR requires ./ instead, which causes Node.js to load the main (react-apollo.cjs.js), and webpack to load the module (react-apollo.esm.js) field in package.json.

This works for both my use cases: tests with Jest & styleguide with webpack, but I might be missing something obvious.

Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever!

@jure
Copy link
Contributor Author

jure commented May 16, 2019

Any thoughts on when this could land?

@jure
Copy link
Contributor Author

jure commented May 28, 2019

So... I could keep updating this with the latest master, but perhaps there's different plans, and this is going to be handled in a different way? I imagine it's not rare for people to have mocked providers in styleguides/storybooks these days?

Anyway, please let me know if this is not relevant or according to your roadmap, so I can stop worrying/checking this MR and implement a local alternative solution.

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @jure!

@hwillson hwillson merged commit b2f3928 into apollographql:master May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could not find "client" in the context of ApolloConsumer when using react-apollo 2.5.3 with MockedProvider
3 participants