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

Packager over-eagerly optimises require values #10816

Closed
notjosh opened this issue Nov 8, 2016 · 4 comments
Closed

Packager over-eagerly optimises require values #10816

notjosh opened this issue Nov 8, 2016 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@notjosh
Copy link
Contributor

notjosh commented Nov 8, 2016

Description

I'm trying to use decimal.js, which works fine in development. But when running the packager in production mode, it fails with:

Unable to resolve module crypto [/path/to]/node_modules/decimal.js/decimal.js: Module does not exist in the module map or in these directories:
[/path/to]/node_modules

Reproduction

npm install decimal.js
react-native bundle --dev=false --platform=ios --entry-file=index.ios.js --bundle-output dist/Something.jsbundle --sourcemap-output dist/Something.jsbundle.map --assets-dest dist

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?

  • React Native version: 0.35.0
  • Platform: iOS
  • Operating System: macOS
@jonrh
Copy link

jonrh commented Feb 21, 2017

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.

@ide
Copy link
Contributor

ide commented Feb 21, 2017

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.

@jonrh
Copy link

jonrh commented Feb 23, 2017

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!

@hramos hramos added the Icebox label Jul 20, 2017
@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

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:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

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.

@hramos hramos closed this as completed Jul 20, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants