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

Does not work without jquery in React-Native #23

Open
IanVS opened this issue Dec 27, 2016 · 2 comments
Open

Does not work without jquery in React-Native #23

IanVS opened this issue Dec 27, 2016 · 2 comments

Comments

@IanVS
Copy link

IanVS commented Dec 27, 2016

React-native has a require function, but it is not the same as that in node.js. One critical difference is that it does not support dynamic requires, and does not obey the try/catch block. All requires are done up-front upon static analysis so that the assets can all be packaged into a bundle.

At any rate, in my React-Native app, I do not use jQuery. I tried to use jquery-deparam, but with no luck. React-Native fails to bundle, because it cannot require(jquery).

Do you think it would be possible to make the jQuery dependency injection more explicit? Perhaps with something like:

import addDeparam from 'jquery-deparam';
import jQuery from 'jquery';

const $ = addDeparam(jQuery); // Adds `deparam` method to jQuery
const deparam = addDeparam(); // define `deparam` function to use standalone
@anacronw
Copy link
Member

hm, I would imagine this problem would exist for other users of UMD and react-native. Basically, it your environment goes into the node js case, when it shouldn't.

@IanVS
Copy link
Author

IanVS commented Dec 27, 2016

Yes, I verified that in my case, removing the first if block (which checks for require) works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants