Hi! First let me just say thank you to all the contributors for their hard work on this brilliant library, keep up the good work!
Problem description
React Native is library/framework to make native mobile apps with JavaScript. When using math.js v3.9.2 as a dependency production builds can no longer be created with the React Native packager. Development builds work correctly (running in a simulator, etc) but not production builds (which are required to publish apps).
Related GitHub issues:
Reproduction
https://github.com/jonrh/react-native-mathjs-bug
I created a small sample React Native project where I investigated a bit the cause of the problem. In the project readme I trace and document things as I went along. The problem can be reproduced by attempting to create a production bundle with the React Native packager by running the following command:
react-native bundle --dev=false --platform=ios --entry-file=index.ios.js --bundle-output something.jsbundle
This produces the following error message:
➜ react-native-mathjs-bug git:(master) ✗ react-native bundle --dev=false --platform=ios --entry-file=index.ios.js --bundle-output something.jsbundle
Loading dependency graph, done.
Unable to resolve module crypto from /Users/jonrh/Desktop/react-native-mathjs-bug/node_modules/decimal.js/decimal.js:
Module does not exist in the module map or in these directories: /Users/jonrh/Desktop/react-native-mathjs-bug/node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
For reference I did attempt the above instructions but without success.
Potential solution
Upgrade decimal.js dependency from v5.0.8 to at least v7.1.1. See here for rationale.
Temporary fix
To be able to make production builds in React Native one possible temporary solution would be to replace the contents of the file node_modules/decimal.js/decimal.js with that of the fixed file here. Raw content link.
Other information
This may not inherently be the fault of decimal.js nor math.js but rather the React Native packager itself. I'm not too sure about it but given that decimal.js v7.1.1 seems to work without issues I'm optimistic that if upgraded this might at least solve the conflict between Math.js and React Native. Thank you for your time and devotion!
Hi! First let me just say thank you to all the contributors for their hard work on this brilliant library, keep up the good work!
Problem description
React Native is library/framework to make native mobile apps with JavaScript. When using math.js v3.9.2 as a dependency production builds can no longer be created with the React Native packager. Development builds work correctly (running in a simulator, etc) but not production builds (which are required to publish apps).
Related GitHub issues:
requirevalues facebook/react-native#10816requiredetection buster MikeMcl/decimal.js#42Reproduction
https://github.com/jonrh/react-native-mathjs-bug
I created a small sample React Native project where I investigated a bit the cause of the problem. In the project readme I trace and document things as I went along. The problem can be reproduced by attempting to create a production bundle with the React Native packager by running the following command:
This produces the following error message:
For reference I did attempt the above instructions but without success.
Potential solution
Upgrade decimal.js dependency from v5.0.8 to at least v7.1.1. See here for rationale.
Temporary fix
To be able to make production builds in React Native one possible temporary solution would be to replace the contents of the file
node_modules/decimal.js/decimal.jswith that of the fixed file here. Raw content link.Other information
This may not inherently be the fault of decimal.js nor math.js but rather the React Native packager itself. I'm not too sure about it but given that decimal.js v7.1.1 seems to work without issues I'm optimistic that if upgraded this might at least solve the conflict between Math.js and React Native. Thank you for your time and devotion!