V3 Upgrade: An error occurred while parsing the WebWorker bundle
mapbox-gl-js version: 3.8.0
browser: Chrome Version 130.0.6723.117
Steps to Trigger Behavior
- Upgrade to mapbox-gl v3
- Run the application
Link to Demonstration
https://jsbin.com/
Cannot easily provide a reproduction.
The application is a react app with webpack 4 and babel 8.
Expected Behavior
It should render the map after following the V3 migration guide.
Actual Behavior
An error occurred while parsing the WebWorker bundle
This happens when importing with
import mapboxgl from 'mapbox-gl'
If i import with previous transpilation suggestion i get another error.
import mapboxgl from '!mapbox-gl'
./node_modules/mapbox-gl/dist/mapbox-gl.js 34:21870
Module parse failed: Unexpected token (34:21870)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
@devsheva I'm seeing the same thing; how did you end up fixing this?
Can you please upgrade to v3.9.4 and see if the problem still occurs?
Sorry for not getting back here when i resolved my issue. I solved it by using the worker loader.
import MapboxWorker from 'worker-loader!mapbox-gl/dist/mapbox-gl-csp-worker'
// Load worker code separately with worker-loader
mapboxgl.workerClass = MapboxWorker // Wire up loaded worker to be used instead of the default