-
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
Building in webpack throws error #21
Comments
The answer apparently is to add some configuration to my webpack config file. It'd be nice if this was documented. |
Known issue: mapbox/mapbox-gl-js#1649 |
@KyleAMathews What configuration did you add to webpack to make it work? I'm having the same issue. The fix suggested at mapbox/mapbox-gl-js#1649 (adding |
Shane, I didn't ever get it to work actually :-)
|
has anyone been able to build successfully with webpack? |
@lafin do you have a complete example for that? I've added the config, but I'm still stuck with the |
thanks for the repo @lafin! unfortunately I can't see any hints as to why this error is still popping up. Any idea where exactly this call is made to the |
It's unclear why despite using {
test: /\.js$/,
include: path.resolve(__dirname, 'node_modules/mapbox-gl/js/render/shaders.js'),
loader: 'transform/cacheable?brfs'
}, I'm still getting
|
@lafin Yeah I see the problem, react-map-gl is bringing in mapbox-gl as a subdependency, so the paths aren't matching. |
Hey @lafin, I tried to run the demo, but I'm getting some errors. Did you miss some deps?
|
@vicapow there might be some polyfill package missing, maybe |
@shanecav @imgettingdeported @KyleAMathews @yuvadm I was able to get it working with webpack by replacing mapbox-gl with a webpack-compatible fork I made: Install cezary/mapbox-gl-js#webpack, worker-loader, shader-loader and json-loader.
and add
to your loaders. The fork hasn't been kept in sync with original, but you can probably replicate the changes I made here. |
@cezary I tried your solution but with no results. Now I get this message when I execute webpack:
Any ideas? |
Not sure if this was solved, but I'm building with webpack successfully. The config part of interest is: var path = require("path");
var webpack = require("webpack");
var transform = require("transform-loader");
module.exports = {
:: ::
resolve: {
:: ::
alias: {
webworkify: 'webworkify-webpack'
}
},
module: {
loaders: [
{
test: /render[\/\\]shaders\.js$/,
loader: 'transform/cacheable',
query: "brfs"
},
{
test: /[\/\\]webworkify[\/\\]index.js\.js$/,
loader: 'worker'
}, I also had to pull in a bunch of dev dependencies: "babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"bootstrap-webpack": "^0.0.5",
"transform-loader": "^0.2.3",
"webworkify-webpack": "^1.0.6" |
@joewood I followed your webpack config but now I am getting this: I see a similar error here: |
@ankitduseja I'm getting the same
|
Also had to |
@shanecav I solved the |
@tsemerad do you mind sharing your webpack.config |
In case any of you are seeing For anyone interested, I only had to add the following to my module.exports = {
resolve: {
alias: {
webworkify: 'webworkify-webpack'
},
...
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
}, {
test: /use_program\.js$/,
loader: 'transform/cacheable?brfs'
},
...
],
postLoaders: [
{
include: /node_modules\/mapbox-gl/,
loader: 'transform',
query: 'brfs'
}
]
},
...
} I also had to install |
@infacq Sorry for the delay. My webpack config is a bit convoluted, but I posted it in a gist here: |
* Add Mapbox GL and related libraries required to serve maps from Webpack. * Update Webpack config based on Mapbox example and https://mikewilliamson.wordpress.com/2016/02/24/using-mapbox-gl-and-webpack-together/, and visgl/react-map-gl#21 (comment). * Create map component and add to SightingsList component. Closes #8
I found myself the smallest change from a webpack config to go through this error, but I got this sources.map is not a function error.
|
I've tried adding a simple react-map-gl into a new app using react-boilerplate but got stuck with an empty single-colour map in dev mode. MWE here: https://github.com/kachkaev/react-boilerplate-react-map-gl-mwe A related issue seems to be here: #96 Has anyone used the same boilerplate? Any ideas? |
Given the new instructions from mapbox on how to build with webpack (see README for link) I will close this for now. If there are react-map-gl specific issues with webpack, the best approach would be to open a PR with a small example, see #112 |
@ankitduseja could you please tell me how did you solve that Cannot find module 'gl' issue? it appears npm hangs when i am trying to install the gl module |
The text was updated successfully, but these errors were encountered: