-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Packager over-eagerly optimises require
values
#10816
Comments
Just had this issue myself by having math.js v3.9.2 as a dependency (which relies on decimal.js v5.0.8). Decimal.js has released a fix which makes it compatible with React Native (v7.0.0 and newer). I created a sample React Native project which demonstrates this issue: https://github.com/jonrh/react-native-mathjs-bug. I've created an issue in the math.js library asking if it would be possible for them to upgrade their decimal.js dependency, that might solve the problem short-term. |
The packager mandates that all requires are statically available, perhaps that could change in the future (cc @cpojer). In the meantime you could write a custom Babel plugin that removes the requires. |
Thanks for the insights @ide, wasn't aware that was the case. As to my own case this issue has been solved with v3.9.2 in math.js thanks to the swift response of the maintainers. Thank you all for your brilliant work in the React Native repo! |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
Description
I'm trying to use decimal.js, which works fine in development. But when running the packager in production mode, it fails with:
Reproduction
Additional Information
decimal.js uses a relatively naive packager-buster, but RN is is folding the constants.
As there's no standard way to omit requires from packagers (that I'm aware of), I've submitted a PR on their side (MikeMcl/decimal.js#42) to thwart the RN packager - but that's a game of cat-and-mouse.
Ideally there'd be an annotation (
/* packager-ignore */
or similar) to prevent this from happening.As this kind of thing exists in other npm modules also, would it make sense to perhaps remove folding of the constants?
The text was updated successfully, but these errors were encountered: