0

I've installed MapBox GL JS v2 in an Angular 14 project. The app loads but the map is empty/grey. The following error is shown in the console:

error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling

The link to the official documentation contains various solutions to try. The first solution is to include the following:

import mapboxgl from '!mapbox-gl';

However, VS Code doesn't like the exclamation mark and gives the error:

Cannot find module '!mapbox-gl' or its corresponding type declarations

The other solutions suggest editing webpack.config.js but this doesn't seem straightforward for an Angular project given the discussion here.

Is there something more simple that I am missing?

Caustix
  • 569
  • 8
  • 26

0 Answers0