Issue with geocoder@>2.0.0 and webpack
See original GitHub issue*Edit: * sorry, meant version >2.0.0 not 1.
Hey guys,
I’ve just upgraded to version 2.0.1 and came across an issue with Webpack. Before I was creating a dependencies bundle:
dependencies: [
'leaflet',
'esri-leaflet-geocoder'
]
That was enough for me to be able to access L.esri.Geocoding
.
Since v2, Webpack is trying trying to pull the source files for the esri-leaflet-geocoder package which are not converted to ES5 hence failing. I added the package to the resolve.alias
list so it points to the compiled file inside dist
. This time I got the same error but with esri-leaflet
, which the geocoder package is trying to require but is going for the source version rather than the dist one.
Tried adding esri-leaflet
to the resolve alias list as well and even specifically adding it to the bundle. In every case webpack is able to build but L.esri
is undefined.
Has anyone come across this issue and/or know how to solve it?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Yep! sorry, I thought he closed it after his answer. This is what I ended up doing in case anyone is interested:
On my webpack.config.js file I modified my exclude regexp to exclude any node_modules packages except the geocoder.
Then:
👍
Prior to version 2.0.0 we always declared the
L.esri.Geocoding
global variable. However shipping 2.0.0 as ES6 modules prevents us from declaring the global as before.https://github.com/Esri/esri-leaflet-webpack-example is a working example with WebPack, Esri Leaflet and Esri Leaflet Geocoder that will use the
babel-loader
plugin compile the Esri Leaflet source on the fly with Babel.Note that you also have to switch to using the CommonJS style syntax to load each peice of leaflet now. Like this https://github.com/Esri/esri-leaflet-webpack-example/blob/master/main.js#L18-L20