mapbox / mapbox/mapbox-gl-geocoder
Import with JSDeliver broken
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 388
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
Hi, this code:
```js
import * as mapboxmapboxGlGeocoder from 'https://esm.run/@mapbox/mapbox-gl-geocoder';
console.log(mapboxmapboxGlGeocoder)
```
will raise the following error:
```
Uncaught TypeError: Cannot read properties of null (reading 'nanoid')
at events.js:2:32
```
So, the package is not importable at all. As far as I can tell, the issue seems to be that if i go to https://cdn.jsdelivr.net/npm/nanoid@3.3.7/+esm, it gives **no default export** (`export default null`), whereas the Mapbox package is set to `import s from"/npm/nanoid@3.3.7/+esm"` and then does `s.nanoid` and that's `null`. So, I believe the solution would be instead to:
```js
import { nanoid } from"/npm/nanoid@3.3.7/+esm"
```
and to rely on the specific export rather than the default export.
Thanks so much!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the browser import from the issue and inspect the generated events.js reference to nanoid. Verify how the package is bundled for esm.run, then confirm the package can be imported without the null nanoid error and that existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100