Improve packaging.
vtkjs was being required on the lean package, though it should have been
optional.
Libraries that someone included geojs twice would fail due to the
babel-polyfill.
MODIFY
src/polyfills.js
src/polyfills.js
+// prevent errors from double inclusion in downstream libraries
+if (!global._babelPolyfill) {
require('babel-polyfill');
+}

MODIFY
src/vtkjs/vtkjsRenderer.js
src/vtkjs/vtkjsRenderer.js
@@ -180,10 +180,10 @@ vtkjsRenderer.supported = function () {
// webpack expects optional dependencies to be wrapped in a try-catch
try {
vtkjsRenderer.vtkjs = require('vtk.js');
- if (!vtkjsRenderer.vtkjs.Rendering && window.vtk.Rendering) {
+ } catch (_error) {}
+ if ((!vtkjsRenderer.vtkjs || !vtkjsRenderer.vtkjs.Rendering) && window.vtk && window.vtk.Rendering) {
vtkjsRenderer.vtkjs = window.vtk;
}
- } catch (_error) {}
return vtkjsRenderer.vtkjs !== undefined;
};

MODIFY
webpack-lean.config.js
webpack-lean.config.js
@@ -19,6 +19,6 @@ module.exports = merge(config, {
// will allow Webpack to create a better error message if a "hammerjs" import fails
umd: 'hammerjs'
},
- 'vtk.js': 'vtk'
+ 'vtk.js': 'vtk.js'
}
});

Improve packaging.

vtkjs was being required on the lean package, though it should have been
optional.

Libraries that someone included geojs twice would fail due to the
babel-polyfill.