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
Prevent error on safely-handled requires using non-static arguments #69
Prevent error on safely-handled requires using non-static arguments #69
Conversation
…ectly within a try block. This should prevent the majority of the use cases that cause issue facebook#65. Implementation per @cpojer's suggestions. Two unit tests added.
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
@cpojer I tried to give issue #65 a go in this PR. Please let me know if this looks like a good starting point to getting a fix in. cc: @TikiTDO who I know has had some pretty significant opinions on this issue. I apologize for doing the same work you were looking into - I couldn't wait much longer due to a large number of dependencies we're using that have moment as a sub-dependency. |
The five errors thrown in the CI were present in the master branch. Didn't want to digress from the issue at hand by fixing them. |
@richardgirges In all honestly, I just want it to work. The sooner the better. If you can get this resolved yesterday my life would be much easier. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Oh nice, thanks for sending this PR. This is definitely the right direction. I'll talk to the Metro team next week about whether this is sufficient or whether we'll need to do other work to make the bundling work properly. |
…d changes in metro bundler facebook/metro#69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@cpojer we can have some news asap about that issue so ? |
Summary
This is the workaround that @cpojer suggested in #65 and should resolve the biggest pain point that developers are experiencing in that issue: using moment.js in React Native. Hopefully this at least serves as a starting point to reaching a decent solution for libraries using non-static
require()
statements.Test plan
1. Two unit tests added:
require()
is nested more than one level deep within atry
statementrequire()
is nested directly within atry
statement2. Ran the following command and got a clean bundle:
3. Added the updates to a
yarn link
ed metro-bundle locally and successfully loaded my react native app w/ moment.js as a dependency.