Wykks / ngx-mapbox-gl

Angular binding of mapbox-gl-js
https://wykks.github.io/ngx-mapbox-gl
MIT License
343 stars 139 forks source link

WebWorker #352

Open vladyslav-semenets opened 2 years ago

vladyslav-semenets commented 2 years ago

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
rajarajankamban commented 2 years ago

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

mokeddes commented 2 years ago

@rajarajankamban @VladislavSemenets

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

rajarajankamban commented 1 year ago

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'
       ....
   })
  }  
}
Tore93 commented 1 year ago

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