question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vaiRkcommented, Oct 25, 2015

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.

loaders: [
    {
        test: /\.jsx?$/,
    loader: 'babel?stage=0',
    exclude: [ new RegExp(nodeModulesPath + '\/(?!esri-leaflet-geocoder).*') ]
    }
]

Then:

import * as Geocoding from 'esri-leaflet-geocoder';
Geocoding.geosearch({...options}).addTo(map);

👍

1reaction
patrickarltcommented, Oct 14, 2015

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

// require leaflet
var L = require('leaflet');
var esri = require('esri-leaflet');
var geocoding = require('esri-leaflet-geocoder');

// since leaflet is bundled into the browserify package it won't be able to detect where the images
// solution is to point it to where you host the the leaflet images yourself
L.Icon.Default.imagePath = 'http://cdn.leafletjs.com/leaflet-0.7.3/images';
Read more comments on GitHub >

github_iconTop Results From Across the Web

host 0.0.0.0 Not working #882 - webpack/webpack-dev-server
I run the webpack-dev-server with params --host 0.0.0.0, then visit the page through my ip, the page shows "Invalid Host header".
Read more >
How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
Read more >
Webpack dev server stops serve asset after wrong module path
Problem reproduces by next steps: Run in terminal npx webpack serve . Result: Compiled successfully . someimg.jpg displays at the page and ...
Read more >
DevServer - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
webpack-dev-server - npm
We do our best to keep issues in the repository focused on bugs, features, and needed modifications to the code for the module....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found