ngx-mapbox-gl icon indicating copy to clipboard operation
ngx-mapbox-gl copied to clipboard

WebWorker

Open vladyslav-semenets opened this issue 3 years ago • 4 comments

Heya guys, how to fix this error:

An 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

SourceBreaker 2022-02-01 18-52-04

vladyslav-semenets avatar Feb 01 '22 16:02 vladyslav-semenets

@VladislavSemenets Try changing the target in tsconfig.json from 'es5' to 'es2015'.

rajarajankamban avatar Feb 09 '22 10:02 rajarajankamban

@rajarajankamban @VladislavSemenets

I too am facing the same issue. I tried just about everything so far with no luck. Any solution or workround ?

mokeddes avatar Jun 20 '22 13:06 mokeddes

Use target as 'es5'. Remove all your maxbox-gl imports across components.

Now added the below in angular.json. So that you avoid using es6 version of it.

"architect": {
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
      "allowedCommonJsDependencies": ["mapbox-gl",]
    },
    "scripts":["node_modules/mapbox-gl/dist/mapbox-gl.js"]
  }
}

In the component where you want to use mapbox-gl

import { Component ... } from "@angular/core";
.
.
declare const mapboxgl: any;
@Component({
...
})

export class Component{
  _mapboxgl: any = mapboxgl;
  map:any;
  buildMap(){
   this.map = new this._mapboxgl.Map({
       container: 'map'
       ....
   })
  }  
}

rajarajankamban avatar Sep 15 '22 06:09 rajarajankamban

Hey there. Facing the same, is there any solution yet?

Tore93 avatar Oct 12 '22 07:10 Tore93