-
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
Introduce static worker version of the bundle for strict CSP environments #8044
Conversation
Feel free to suggest different naming — maybe |
This looks good to me. Is the script loaded only when the first worker is initialized? Is this ok or would first load be faster if we prefetch it? This is something we don't need to address now.
Is it possible to default this to the path the current script was loaded from? So that if a user puts both files in the same directory and doesn't rename them they don't need to specify this?
I think both files should share a name to show that they go together. For example, Other possible names are
|
If the map isn't instantiated on load, this can be addressed on the app side with: <link rel="preload" href=".../mapbox-gl-worker.js" as="script">
We could, but I think that with the current prevalence of bundlers and fragility of regexp script heuristics, it's not worth doing. If someone wants to switch to this special bundle, I think they won't have a problem adding a short line of code, and it will be reliable.
Good point! I can rename to |
👍 |
Thanks @mourner! |
Closes #6058. Adds a
build-csp
script that builds a static worker version of the GL JS bundle —dist/mapbox-gl-csp.js
anddist/mapbox-gl-csp-worker.js
, which would be included in the distribution of the next release. The only additional step to using this bundle is settingmapboxgl.workerUrl
manually before instantiating the map:You can test this out locally with the
debug/csp-static.html
page.Bundle size comparison
Launch Checklist
write tests for all new functionalitypost benchmark scores