feat: Harden checking for optional dependencies.
Fixes
Note this has been marked as a feature so that major build changes are
in a new minor version instead of a bug fix version.
MODIFY
src/mapInteractor.js
src/mapInteractor.js
@@ -718,6 +718,9 @@ var mapInteractor = function (args) {
var Hammer;
try {
Hammer = require('hammerjs');
+ if (!Hammer || !Hammer.Manager) {
+ Hammer = undefined;
+ }
} catch (_error) {}
if (Hammer !== undefined) {
var recog = [],

MODIFY
src/svg/svgRenderer.js
src/svg/svgRenderer.js
@@ -681,6 +681,9 @@ svgRenderer.supported = function () {
// webpack expects optional dependencies to be wrapped in a try-catch
try {
svgRenderer.d3 = require('d3');
+ if (!svgRenderer.d3 || !svgRenderer.d3.rgb) {
+ svgRenderer.d3 = undefined;
+ }
} catch (_error) {}
return svgRenderer.d3 !== undefined;
};

MODIFY
src/vtkjs/vtkjsRenderer.js
src/vtkjs/vtkjsRenderer.js
@@ -184,6 +184,9 @@ vtkjsRenderer.supported = function () {
if ((!vtkjsRenderer.vtkjs || !vtkjsRenderer.vtkjs.Rendering) && window.vtk && window.vtk.Rendering) {
vtkjsRenderer.vtkjs = window.vtk;
}
+ if (!vtkjsRenderer.vtkjs || !vtkjsRenderer.vtkjs.Rendering) {
+ vtkjsRenderer.vtkjs = undefined;
+ }
return vtkjsRenderer.vtkjs !== undefined;
};

feat: Harden checking for optional dependencies.

Fixes #1056.

Note this has been marked as a feature so that major build changes are
in a new minor version instead of a bug fix version.