-
-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expo / React Native not having support for 'events' #1847
Comments
hmmm I wonder if here: msw/src/node/SetupServerApi.ts Lines 53 to 91 in 15e3006
maybe we can move to a dynamic import?
or something along those lines to avoid a static build failure? and fix support? |
Is there any update? And how can I help? |
I haven't ever run anything with react-native or expo, and haven't had a chance to get everything setup If you install Another option could be - if you |
https://github.com/browserify/events this is the events polyfill that I believe should work across js engines and maybe good enough to replace the issue in your environment? |
One other option might be something like - https://github.com/parshap/node-libs-react-native which uses that events module under the hood it seems (to this was a very cursory look) |
I wonder, do React Native bundlers support some export conditions, like // src/utils/nodeEvents.ts
export * from 'node:events' // src/utils/nodeEvents.react-native.ts
export {} // package.json
{
"exports": {
"./src/utils/nodeEvents.ts": {
"react-native": "./src/utils/nodeEvents.react-native.ts",
"default": "./src/utils/nodeEvents.ts"
}
}
}
|
I went with @mattcosta7's suggestion with the lazy import of |
Did you try those changes with the bare React-Native project? Or just make the changes and build it? |
@DogukanTansuk, no, I haven't. I'm not a React Native developer and I don't even have enough space on my machine to install XCode to run React Native (but I heard you don't need it?). You are free to give those changes a try by installing MSW from a particular branch/commit, which is supported by all package managers 🙌 By the way, if you work with React Native, you can help us a lot by testing this, and other things out in regards to MSW integration. We are looking for someone to pave the way for MSW integration in React Native: report issues, try releases, submit a usage example, and validate our Integration docs. If that sounds interesting to you, let me know. |
@kettanaito I would love to help you with that one. Me and my team currently renewing a bank application with React Native CLI. We are using MSW for mocking endpoint results on test cases. It perfectly works fine with |
@DogukanTansuk, that looks like a compiler error telling you that the file you are requiring ( |
Released: v2.0.7 🎉This has been released in v2.0.7! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
In my index.js file everything looks good, there's no configuration problem. The issue was fixed with the new patch that you released.
Whoever has the same problem as mine this update will fix your issue by updating your current version of msw. |
@DogukanTansuk, over the moon to hear that! Thanks! |
Do you want me to prepare the example with Bare React-Native CLI? |
@DogukanTansuk, it's an important choice to decide what kind of example to feature. I think it's a good practice to find something in-between of real-world usage and barebone-ness, if I may say so. While we cannot feature an example of each and every possible tech the developers may be using, something like a common ground example to let them branch from would be nice. For example, is React Native CLI commonly used? I hear a lot about projects like Metro. I think there's nothing wrong with featuring a minimal example using the stack most folks employ to build React Native apps. There's always been previous attempts to add a React Native example, which were sadly ignored by me due to the lack of time. I have a bit more resources available right now, so lets make the official React Native example happen!
|
You have two options to go with in React Native, either you choose React Native CLI or Expo CLI. Most people use Redux/Redux-Toolkit with Saga or Thunk. I can prepare a couple of project examples including Redux/Redux-Toolkit. Also, we can provide some jest test examples. Our banking project includes most of the tech stack that I mentioned. Also, we have a SaaS project which has a mobile application written with Expo CLI. |
Prerequisites
Environment check
msw
versionNode.js version
21.1.0
Reproduction repository
https://github.com/Cocolis-1/blank-expo/tree/feat/msw
Reproduction steps
Try to start the bundler using yarn start and start your dev client.
Current behavior
You should see the following error:
Expected behavior
MSW should not depend on node:events (if possible) so that React Native users can use it.
I think the commit introducing node:events is this one.
Let me know if I can help in any way!
Thanks!
The text was updated successfully, but these errors were encountered: