mapbox / mapbox/mapbox-gl-geocoder

Import with JSDeliver broken

Open
#524 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.