Skip to content
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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/source/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

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 ☝️

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.

return new Worker(self);
};

Expand Down
6 changes: 4 additions & 2 deletions webpack.config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const path = require('path');
* Mapbox GL JS uses the webworkify module by default, and that module
* does things very specific to browserify's module loading system. In this
* configuration, we alias webworkify to webworkify-webpack to add webpack
* support.
* support. NOTE: there is a known caveat when using 'eval'-related devtool
* settings, make sure to double-check your configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide more context here? What is the caveat? What should developers check their configurations for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the confusion, I'm afraid English is not my first language. I was referring to this part of webworkerify-webpack's README:

While developing make sure not to set webpack's devtool option to be with some eval configuration because from 1.1.0 version it won't work

*/
module.exports = {
entry: './test.js',
Expand All @@ -59,5 +60,6 @@ module.exports = {
loader: 'transform',
query: 'brfs'
}]
}
},
devtool: 'cheap-source-map' // don't use eval-related options
Copy link
Contributor

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?

Copy link
Author

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.

}