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

Add support for using third party worker-loader plugins #10219

Merged
merged 7 commits into from
Dec 17, 2020

Conversation

arindam1993
Copy link
Contributor

@arindam1993 arindam1993 commented Dec 16, 2020

This PR adds support for using WebWorker loader's from external build-systems such as Webpack or rollup.
Both their worker-loader plugins expose the bundled webworker code as a class, that when instantiated exposes the same interface as a raw Worker, i.e it has the postMessage and onMessage hooks. This means we can seamlessly swap out the global worker with this custom class to allow users to use these tools

PR for extended documentation is here:
https://github.com/mapbox/mapbox-gl-js-docs/pull/461

Launch Checklist

  • briefly describe the changes in this PR
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Add support for bundling the WebWorker with external module bundlers.</changelog>

src/index.js Outdated
* @returns {Object|null} a Class object an instance of which exposes the `Worker` interface.
* @example
* import mapboxgl from 'mapbox-gl/mapbox-gl-csp.js'
* import MapboxGLWorker from 'mapbox-gl/mapbox-gl-csp-worker.js'
Copy link
Member

Choose a reason for hiding this comment

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

Should we explicitly use WebPack's worker loader here as an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants