From a2fda495333f3508ee7b746fdffe23f067c7de1b Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Wed, 28 Feb 2018 21:01:31 -0500 Subject: [PATCH] Allow Hammer.js to exist as an npm-installed package When resolving "require('hammerjs')", this will look for npm-installed "hammerjs" packages to link to, in addition to a global "Hammer" variable. Since "hammerjs" is an npm-optional dependency of GeoJS, if Webpack rebundles GeoJS in a downstream project, it will be smart enough to elide any "require('hammerjs')" statements in the built GeoJS. Without this change, downstream Webpack is not able to elide "require('Hammer')" usages (since the module name doesn't match the optional dependency name). --- webpack.config.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index f5d6b71577..f8152574ba 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -43,7 +43,12 @@ module.exports = { }, externals: { d3: 'd3', - hammerjs: 'Hammer' + hammerjs: { + root: 'Hammer', + commonjs: 'hammerjs', + commonjs2: 'hammerjs', + amd: 'hammerjs' + } }, plugins: [ define_plugin,