-
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
Some NPM packages don't work #406
Comments
I can't get it work with
Take a look at the |
I've also had a hard time getting some modules to work. I was able to get lodash to work by using the It looks like the packager thinks the exported function is a factory for creating the module, but the factory (in lodash) is not actually detecting a node environment and instead the export ends up being undefined. I'll keep digging in the bundle and report if I find anything useful. |
I had to use the lodash-cli to build a node version for React: |
It looks like, at least in the case of backbone (and probably regular underscore/lodash), that it checks for a Why does the packager set I guess, the follow up question would be, if we do allow AMD style defines, why aren't they working for lodash, et. al. |
@nicinabox The |
I think it's been deprecated though. |
When I comment out this |
For the amd issue, here's our code responsible for it. https://github.com/facebook/react-native/blob/master/packager/react-packager/src/DependencyResolver/haste/polyfills/require.js#L597 I'm unsure why we define this global. |
Woops @jgable beat me to it! |
package he shows same issue. // Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
typeof define == 'function' &&
typeof define.amd == 'object' &&
define.amd
) {
define(function() {
return he;
});
} else if (freeExports && !freeExports.nodeType) {
if (freeModule) { // in Node.js or RingoJS v0.8.0+
freeModule.exports = he;
} else { // in Narwhal or RingoJS v0.7.0-
for (var key in he) {
has(he, key) && (freeExports[key] = he[key]);
}
}
} else { // in Rhino or a web browser
root.he = he;
} |
I have the same issue with
|
fixed via #581 will publish v0.3.2 soon |
Summary: See facebook#406 Made sure the jest tests pass but didn't know a good unit test to add for this. Closes facebook#427 Github Author: Jacob Gable <jacob.gable@gmail.com> Test Plan: * ./runJestTests * start app and click around
Summary: See facebook#406 Made sure the jest tests pass but didn't know a good unit test to add for this. Closes facebook#427 Github Author: Jacob Gable <jacob.gable@gmail.com> Test Plan: * ./runJestTests * start app and click around
Summary: See facebook#406 Made sure the jest tests pass but didn't know a good unit test to add for this. Closes facebook#427 Github Author: Jacob Gable <jacob.gable@gmail.com> Test Plan: * ./runJestTests * start app and click around
Naive question alert, but why not support AMD? |
@broonage: we're building a new js environment (others are browser, web worker, node) and need to figure out what we support. We want to support as few things as possible so that it is easier to maintain and has less bugs overall. It turns out that the community pretty much settled on commonjs and not AMD so this is what we chose to implement. Having two things to do the same thing is usually not a great idea. If in the future AMD makes a big comeback and there are big incentives to implement it, we could. But trying to keep it as simple as possible for now :) |
@vjeux: Thanks, good to know. I'm trying to re-use some existing web modules in a project which use AMD (define), so I have to edit all the files so they are working with require() calls and module.exports=CoolReactNativeModule. I guess no other way about it. :) |
@cpojer would suggest you to write a codemod for this :p |
I've come across a few npm modules that don't appear to work correctly. Notably, event-emitter has issues importing
es5-ext/object/assign
, and debug doesn't appear to work with the chrome dev-tools. I suspect that small alterations to the module themselves (to take into account yet another working environment) may be necessary, but there could also be issues with the packager, too.The text was updated successfully, but these errors were encountered: