Better checks for external modules.
D3 and HammerJS are intended to be optional modules.  Consumers of geojs (at least those that don't use webpack) improperly report that these modules are always available.
MODIFY
src/d3/d3Renderer.js
src/d3/d3Renderer.js
@@ -635,7 +635,11 @@ registerRenderer('d3', d3Renderer);
* @returns {boolean} true if available.
*/
d3Renderer.supported = function () {
- return !!__webpack_modules__[require.resolveWeak('d3')]; // eslint-disable-line
+ if (!__webpack_modules__[require.resolveWeak('d3')]) { // eslint-disable-line
+ return false;
+ }
+ var d3 = require('d3');
+ return d3 !== undefined;
};
/**

MODIFY
src/mapInteractor.js
src/mapInteractor.js
@@ -751,6 +751,7 @@ var mapInteractor = function (args) {
(usedInputs.pan || usedInputs.rotate) &&
__webpack_modules__[require.resolveWeak('hammerjs')]) { // eslint-disable-line
var Hammer = require('hammerjs');
+ if (Hammer !== undefined) {
var recog = [],
touchEvents = ['hammer.input'];
if (usedInputs.rotate) {
@@ -771,13 +772,14 @@ var mapInteractor = function (args) {
m_touchHandler.manager.on(touchEvent, m_this._handleTouch);
});
}
+ }
return m_this;
};
////////////////////////////////////////////////////////////////////////////
/**
- * Disiconnects events to a map. If the map is not set, then this does
+ * Disconnects events to a map. If the map is not set, then this does
* nothing.
* @returns {geo.mapInteractor}
*/

Better checks for external modules.

D3 and HammerJS are intended to be optional modules.  Consumers of geojs (at least those that don't use webpack) improperly report that these modules are always available.