mapbox / mapbox-gl-draw

Draw tools for mapbox-gl-js
https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
ISC License
952 stars 593 forks source link

Library crashing with source-map-loader in angular 15 #1147

Open samYnsat opened 1 year ago

samYnsat commented 1 year ago

I have just installed this mapbox-gl-draw into my angular 15 project with the types. Each type I import the it like this: import * as MapboxDraw from '@mapbox/mapbox-gl-draw'; It gives me an error about other pre-installed library called sourece-map-loader I tried to downgrade the version until 1.2.0 that is the first one but the problem contiues.

mapbox-gl-js version: 2.12.0 mapbox-gl-draw version: 1.3.0

Steps to Trigger Behavior

  1. Build an angular 15 project
  2. npm download mapbox.gl-js and mapbox-gl-draw
  3. import mapbox-gl-draw into the project to add MapboxDraw

Expected Behavior

Normal compiling.

Actual Behavior

I have an error in the index.js `Compiled with problems:

ERROR in ./node_modules/@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.js

Module build failed: .../node_modules/source-map-loader/dist/cjs.js:3 import loader, { raw } from "./index.js";`

Thank you very much!

samYnsat commented 1 year ago

For now, the only thing i could do to fix this it has been to downgrade to Angular 14 and change the tsconfigfile.json almost completely.

neodescis commented 1 year ago

I have maplibre and mapbox draw working just fine in Angular 15. I would suggest you set esModuleInterop to true in your top-level tsconfig, and add also install @types/mapbox__mapbox-gl-draw. You'll then need to remove the "* as" from your import: import MapboxDraw from '@mapbox/mapbox-gl-draw';