aboutsummaryrefslogtreecommitdiffstats
path: root/src/exports.js
diff options
context:
space:
mode:
authorjrburke <jrburke@gmail.com>2013-01-30 15:32:19 -0800
committerDave Methvin <dave.methvin@gmail.com>2013-04-03 20:10:42 -0400
commitb6dd1c67a63d19ff4b22b893f4d47f80f0d47fd9 (patch)
treea694375c392f5190100b1592994338f581b76628 /src/exports.js
parent937b2b194d8516d82f2c51c1573ec4316e2960b8 (diff)
downloadjquery-b6dd1c67a63d19ff4b22b893f4d47f80f0d47fd9.tar.gz
jquery-b6dd1c67a63d19ff4b22b893f4d47f80f0d47fd9.zip
Remove the define.amd.jQuery check, close gh-1150.
Cherry picked from 2.0 master 34c4e122a333bbfc80bd4f6e79db20f3a73ae5b3 Conflicts: src/exports.js
Diffstat (limited to 'src/exports.js')
-rw-r--r--src/exports.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/exports.js b/src/exports.js
index 88def50ba..365c97bf6 100644
--- a/src/exports.js
+++ b/src/exports.js
@@ -1,18 +1,21 @@
-// Expose jQuery to the global object
-window.jQuery = window.$ = jQuery;
+if ( typeof module === "object" && typeof module.exports === "object" ) {
+ // Expose jQuery as module.exports in loaders that implement the Node
+ // module pattern (including browserify). Do not create the global, since
+ // the user will be storing it themselves locally, and globals are frowned
+ // upon in the Node module world.
+ module.exports = jQuery;
+} else {
+ // Otherwise expose jQuery to the global object as usual
+ window.jQuery = window.$ = jQuery;
-// Expose jQuery as an AMD module, but only for AMD loaders that
-// understand the issues with loading multiple versions of jQuery
-// in a page that all might call define(). The loader will indicate
-// they have special allowances for multiple jQuery versions by
-// specifying define.amd.jQuery = true. Register as a named module,
-// since jQuery can be concatenated with other files that may use define,
-// but not use a proper concatenation script that understands anonymous
-// AMD modules. A named AMD is safest and most robust way to register.
-// Lowercase jquery is used because AMD module names are derived from
-// file names, and jQuery is normally delivered in a lowercase file name.
-// Do this after creating the global so that if an AMD module wants to call
-// noConflict to hide this version of jQuery, it will work.
-if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
- define( "jquery", [], function () { return jQuery; } );
+ // Register as a named AMD module, since jQuery can be concatenated with other
+ // files that may use define, but not via a proper concatenation script that
+ // understands anonymous AMD modules. A named AMD is safest and most robust
+ // way to register. Lowercase jquery is used because AMD module names are
+ // derived from file names, and jQuery is normally delivered in a lowercase
+ // file name. Do this after creating the global so that if an AMD module wants
+ // to call noConflict to hide this version of jQuery, it will work.
+ if ( typeof define === "function" && define.amd ) {
+ define( "jquery", [], function () { return jQuery; } );
+ }
}