-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create example that bundles react-map-gl using webpack #112
Comments
FYI, Mapbox has posted their official Webpack config that contains all the loaders needed to get Mapbox GL JS working in Webpack: https://github.com/mapbox/mapbox-gl-js/blob/master/webpack.config.example.js I was getting errors on the page before adjusting my config to match theirs. No errors anymore, but also no tiles. Going to see if setting my |
@owap - Awesome, I have added this info to the README file. |
So yeah, MapBox officially ditched the webpack support: mapbox/mapbox-gl-js#3235 Now, we are supposed to require directly the .js file: https://github.com/mapbox/mapbox-gl-js#using-mapbox-gl-js-with-other-module-systems What would be the best solution to integrate |
I think the solution is to have react-map-gl import |
Hi @contra, |
Alright, definitive answer - Method 1: You can still use the old way! Update webworkify-webpack once borisirota/webworkify-webpack#21 is published and your existing stuff should work fine. Method 2: Alternatively, you can remove all of the old hacks (webworkify, glsl compile, etc.) and set up an alias which should work in most cases: resolve: {
alias: {
'mapbox-gl/js/mapbox-gl.js': 'mapbox-gl/dist/mapbox-gl.js'
}
} |
Has anyone gotten @contra 's aliasing method working(I tried and failed with 1.7)? Transforming |
@davidhampgonsalves Aliasing (method 2) should work fine with no other hacks. Method 1 w/ webworkify-webpack and the brfs hacks is the same as the old instructions, but you have to use my fork of webworkify-webpack for it to work until they merge my PR. |
Thanks @contra. I couldn't get that working but was able to with
I added the transform alias to handle https://github.com/uber/react-map-gl/blob/master/src/utils/transform.js#L23 |
my head is spinning with this stuff, I've tried aliasing the above to get react-map-gl going with webpack, but all I'm getting is:-
From Does the webworkify dependency need to be bumped now? Has anyone got an up-to-date gist or something of this working? 😄 🔫 |
@gaving If you are getting that error then |
@davidhampgonsalves 👍 Thanks for the tip, this got things working. Turns out the paths weren't resolving correctly (I'm using nwb and had stripped out __dirname thinking substituting './node_modules' would do it, but it turns out you need the full absolute path). Paths didn't need adjusted. Thanks again for the heads up, been a good couple of hours getting to the bottom of that! |
worked for me
|
@cpietsch which version of
This may be caused by the introduction of flow in UPD: I got this fixed. It turned out I did not have Flow transpiler in my babel config.
"plugins": [
"...other plugins...",
"transform-flow-strip-types"
],
loaders: [{
test: /\.js$/,
loader: 'babel',
// exclude: /node_modules/, // remove
exclude: /node_modules\/(?!mapbox-gl\/js)/, // add
}, {
// ...
|
For all the folks that followed this issue, please note that a working webpack example can be found in the deck.gl repo. I will land a PR soon to reference this in the Readme. Sorry for the wait! 😁 |
I am trying use this package but i get this error
|
You should not see this error in the browser. If you are trying to run mapbox-gl in node, it will try to load |
@Shadowman4205 what version of |
@apercu That link seems to be broken - https://github.com/uber/deck.gl/tree/master/exhibits/webpack |
@G2Jose Thanks, link updated |
@ibgreen My brain is going to explode. I tried ur solution but i get errors on installing gl i am getting this error.
but i get this error
@abmai i installed last version. |
@Shadowman4205 last version being The FWIW - you should try the following, in order to get around requiring const isBrowser = require('is-browser'); // npm package
var MapGL = 'div';
if (isBrowser) {
MapGL = require('react-map-gl');
}
class Map extends React.Component {
render() {
return (
<MapGL ... />
)
}
} |
@abmai
|
|
I'm trying to use the react-map-gl module with Webpack 2 but without babel (to avoid debugging wiht sourcemaps). I followed the instructions and have
in my webpack.config.js. When I start webpack I get the following error:
Does anyone know why react-map-gl's import of mapbox-gl is not aliasing to ./node_modules/mapbox-gl/dist/mapbox-gl.js? It seems like webpack should correctly process the import and avoid using the mabox source with the typescript in it. Thanks. |
@calocan Looks like you are using react-map-gl v2. This has been fixed in v3. |
Thanks, I missed that update. That fixed it. |
react-map-gl is only tested using browserify, and unfortunately it appears to be non trivial getting react-map-gl and mapbox-gl-js working with webpack.
While we are not ready to commit to formal support for webpack, it would be great to have an example that could serve as a starting point for webpack users.
The text was updated successfully, but these errors were encountered: