-
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
Requiring Node modules that support AMD causes them to try to expose themselves as AMD #398
Comments
To add to this, if one goes into Exoskeleton's source, and adds the following (at the top of the file, starting at line 10): (function(root, factory) {
// Set up Backbone appropriately for the environment.
if (typeof define === 'function' && define.amd) {
console.log('Using AMD'); // <----------------- ADD THIS
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
root.Backbone = root.Exoskeleton = factory(root, exports, _, $);
});
} else if (typeof exports !== 'undefined') {
var _, $;
try { _ = require('underscore'); } catch(e) { }
try { $ = require('jquery'); } catch(e) { }
factory(root, exports, _, $);
} else {
root.Backbone = root.Exoskeleton = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
} You will see |
This also happens with // Export lodash.
var _ = runInContext();
// Some AMD build optimizers like r.js check for condition patterns like the following:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
console.log('Using AMD'); |
Thanks for investigating. @amasad will investigate why we have define as a global when he gets a chance |
I think it's probably related to #406 |
Closing this one, #406 is tracking it. |
Most Node packages expose themselves via AMD, CommonJS (
module.exports
), or globals depending on the environment. I understand that React-native does indeed support AMD, but is there any way to force modules to be treated as CommonJS?Steps to reproduce:
Create a new React Native project
Run
npm install exoskeleton
(this, along with jsSHA, are the first two libraries I noticed this with)Add the following to index.ios.js:
Notice how, in the debug console, an empty object is logged.
The text was updated successfully, but these errors were encountered: