Skip to content
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

React native SDK issue on Monorepo #412

Open
master96 opened this issue Mar 28, 2024 · 3 comments
Open

React native SDK issue on Monorepo #412

master96 opened this issue Mar 28, 2024 · 3 comments
Labels
bug Something isn't working package: sdk/react-native Issues that affect the react native SDK. waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.

Comments

@master96
Copy link

Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the code in this library. If you're not sure whether the problem you are having is specifically related to this library, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here and clicking "submit a request", or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug
error: Error: Unable to resolve module event-target-shim/es5 from /Users/vajage/Desktop/***/packages/native/node_modules/@launchdarkly/react-native-client-sdk/dist/src/polyfills/CustomEvent.js: event-target-shim/es5 could not be found within the project or in these directories:
node_modules
../../node_modules

To reproduce
Install Launchdarkly on monorepo with react and react-native

Expected behavior
A clear and concise description of what you expected to happen.

Logs
error: Error: Unable to resolve module event-target-shim/es5 from /Users/vajage/Desktop/provider-platform-app/packages/native/node_modules/@launchdarkly/react-native-client-sdk/dist/src/polyfills/CustomEvent.js: event-target-shim/es5 could not be found within the project or in these directories:
node_modules
../../node_modules
3 | * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Events/CustomEvent.js#L21
4 | */

5 | import { Event } from 'event-target-shim/es5';

SDK version
^10.0.5

Language version, developer tools
"react-native": "0.72.4"

OS/platform
Mac

Additional context
Add any other context about the problem here.

@master96 master96 added bug Something isn't working package: shared/common Label for issues affecting the shared/common package. labels Mar 28, 2024
@yusinto
Copy link
Contributor

yusinto commented Apr 1, 2024

@master96 Please provide more information; what kind of monorepo tool are you using? And please provide a minimal reproducible project which demonstrates the bug so I can reproduce. Thank you.

@yusinto yusinto added waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness. package: sdk/react-native Issues that affect the react native SDK. and removed package: shared/common Label for issues affecting the shared/common package. labels Apr 1, 2024
@navignaw
Copy link

navignaw commented May 9, 2024

Seeing the same issue with a yarn (classic) workspace. We have a monorepo set up with both Expo and Next.js, though I'm not sure how relevant the latter is. I did some research and it looks like there is an alternative polyfill that we could try: facebook/react-native#38004 (comment)

I'm not really sure if importing event-target-shim/es5 makes sense on React Native since according to the docs, it's primarily for IE11:

If you want to support IE11, use import {} from "event-target-shim/es5" instead. It's a transpiled code by babel. It depends on @baebl/runtime (^7.12.0) package.

Also, fwiw, the link in the code points to a new React Native implementation that no longer uses event-target-shim, but rather implements its own polyfill.

@navignaw
Copy link

I was able to fix this by removing the event-target-shim/es5 code and instead replacing it with the latest polyfill from react-native.

In particular, I copied over these two files on the latest main: EventPolyfill.js and CustomEvent.js, thanks to the comment here. This removed the dependency on event-target-shim/es5 and successfully solved the problem. However because I patched the JS files directly it's not clear to me whether this passes typechecking (as the source files are written with Flow instead of TypeScript).

If this is an acceptable solution, I'd love to see it merged upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package: sdk/react-native Issues that affect the react native SDK. waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.
Projects
None yet
Development

No branches or pull requests

3 participants