From 06654d81ec76208d7a2566a4736ab26b2da79e74 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 6 May 2016 17:15:44 -0400 Subject: [PATCH 1/3] Push internal $ onto window object if there isn't one there already --- src/index.js | 5 +++++ webpack.config.js | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 9a5e2282a6..0f71a2aa54 100644 --- a/src/index.js +++ b/src/index.js @@ -65,8 +65,13 @@ module.exports = $.extend({ version: require('./version'), util: require('./util'), + jQuery: $, d3: require('./d3'), gl: require('./gl'), canvas: require('./canvas'), gui: require('./ui') }, require('./registry')); + +if (!window.$) { + window.$ = $; +} diff --git a/webpack.config.js b/webpack.config.js index 634e3c5394..eb640bd58b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,7 +26,6 @@ module.exports = { } }, externals: { - jquery: 'jQuery', d3: 'd3' }, plugins: [ From f7897a3a0d6e8abee1cc221063705211af0c7704 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Mon, 9 May 2016 11:36:14 -0400 Subject: [PATCH 2/3] Remove JQuery from vendor bundle; move JQuery copyright statement to main bundle --- src/index.js | 4 ++++ src/vendor.js | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 0f71a2aa54..0b69bf7cb0 100644 --- a/src/index.js +++ b/src/index.js @@ -18,6 +18,10 @@ * @copyright 2015, Brandon Jones, Colin MacKenzie IV * @license MIT * + * JQuery + * @copyright jQuery Foundation and other contributors + * @license MIT + * * earcut * @copyright 2016, Mapbox * @license ISC diff --git a/src/vendor.js b/src/vendor.js index af90e0ec64..99db4b7f47 100644 --- a/src/vendor.js +++ b/src/vendor.js @@ -1,17 +1,11 @@ // License headers that will be preserved in distributed bundles. -/** - * JQuery - * @copyright jQuery Foundation and other contributors - * @license MIT - */ /** * d3 * @copyright 2010-2016, Michael Bostock * @license BSD-3-Clause */ var globals = { - d3: require('d3'), - $: require('jquery') + d3: require('d3') }; module.exports = globals; From 7e8717686b98a4d7b7aba1734bda5ce8878eab7e Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Mon, 9 May 2016 11:37:09 -0400 Subject: [PATCH 3/3] Use a safer conditional when pushing $ to global object --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 0b69bf7cb0..aa21e38a43 100644 --- a/src/index.js +++ b/src/index.js @@ -76,6 +76,6 @@ module.exports = $.extend({ gui: require('./ui') }, require('./registry')); -if (!window.$) { +if (window && !window.$) { window.$ = $; }