-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix webpack support #2857
Fix webpack support #2857
Conversation
There is a known caveat with workerify-webpack which can result in errors in some webpack environments; the worker function passed to workerify should not be anonymous. This one-line change names the function 'MapboxGlWorker' and resolves the issue.
Adds a note about avoiding 'eval'-related devtool settings in webpack configurations, which can result in errors with workerify-webpack.
@@ -14,7 +14,7 @@ var rewind = require('geojson-rewind'); | |||
var GeoJSONWrapper = require('./geojson_wrapper'); | |||
var vtpbf = require('vt-pbf'); | |||
|
|||
module.exports = function(self) { | |||
module.exports = function MapboxGlWorker(self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand borisirota/webworkify-webpack#9 correctly, this shouldn't be necessary with webworkify-webpack 1.1.1, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fixed, correct. However, I'm on webworkify-webpack@1.1.1
and mapbox-gl@0.20.1
using the recommended webpack.config.js setup. This produced the error mentioned in the pull request. Adding a name to the function fixed the issue for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this line ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the time being, webworkify-webpack needs a named function to operate correctly.
If naming the function is the only way to fix webpack then I think we should do it. There are no substantial cons.
|
I submitted borisirota/webworkify-webpack#13 yesterday, and v1.1.3 appears to fix the |
Dang, you beat me @austinhyde. In addition to that I had to remove But yes, I can confirm this shouldn't be an issue with |
Great! Can we close this issue now @austinhyde @bensleveritt @michaelhue? |
I think that if @michaelhue can confirm webworkify-webpack v1.1.3 fixes his issue, then yes. Otherwise, this is a good stopgap with no drawbacks, until it can be addressed in webworkify-webpack. |
Hmm... just ran into this issue: borisirota/webworkify-webpack#13 (comment) I'd hold off on closing/merging this for now. |
@austinhyde |
Sounds like the upstream fix is underway. I prefer to wait for that! |
Just re-read this. I agree. |
@@ -59,5 +60,6 @@ module.exports = { | |||
loader: 'transform', | |||
query: 'brfs' | |||
}] | |||
} | |||
}, | |||
devtool: 'cheap-source-map' // don't use eval-related options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why inline-source-map
over source-map
orinline-source-map
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found cheap-source-map
to be a good tradeoff but of course any other non-eval setting will do.
I'm actually going to recommend merging this. There's some bigger issues going on in webworkify-webpack that I'm trying to work through, and this is a harmless fix in the meantime. |
Replaced by #2887 (bringing the PR within the Mapbox organization to make final edits easier) |
Fixes a known issue with anonymous functions and workerify-webpack in webpack-based build environments. See original issue.
Actual error message: