v3.25.0: Switching the ESM entry point to named exports not compatible with latest MapboxSearchBox (search-js-web)
bug :lady_beetle:auto-triaged
### mapbox-gl-js version
v3.25.0
### Browser and version
Chrome Version 149.0.7827.200
### Expected behavior
After switching the ESM entry point to named exports (`import * as mapboxgl from 'mapbox-gl/esm'`), binding the Map object to the MapboxSearchBox object should be possible.
### Actual behavior
After creating the map object using the new ESM entry point, trying to bind the map to the search box throws a type error:
```js
import * as mapboxgl from 'mapbox-gl/esm';
...
this.map = new mapboxgl.Map;
...
const searchBox = new MapboxSearchBox();
searchBox.bindMap(this._map!);
```
```
Argument of type 'import("/node_modules/mapbox-gl/dist/esm/mapbox-gl").Map' is not assignable to parameter of type 'mapboxgl.Map'.
Excessive stack depth comparing types 'Map$1' and 'Map$1'.
```
The source of the issue is the `mapboxgl` import path in the `MapboxSearchBox` component [@mapbox/search-js-web/dist/components/MapboxSearchBox.d.ts](https://www.npmjs.com/package/@mapbox/search-js-web?activeTab=code) which is still using the legacy path (`import mapboxgl from 'mapbox-gl';`).
The workaround is to cast the map instance as `any`, but an update to the `search-js-web` is needed to reflect the new import path.
```js
searchBox.bindMap(this._map! as any);
```
### Link to the demonstration
_No response_
### Steps to trigger the unexpected behavior
_No response_
### Relevant log output
```shell
```
1 条评论