mapbox / mapbox/mapbox-gl-js

Provide a ESM module build

Open
#8,676 29 comments 25 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use the library for the first time and the quickstart tutorial example for basic installation doesn't work as expected.

Importing the library like so:

```javascript
import mapboxgl from 'mapbox-gl'
```

Throws the error:

```
Uncaught SyntaxError: The requested module 'node_modules/mapbox-gl/dist/mapbox-gl.js' does not provide an export named 'default'
```

**mapbox-gl-js version**: 1.2.1

**browser**: Chrome

### Steps to Trigger Behavior

1. `yarn add mapbox-gl`
2. In a module: `import mapboxgl from 'mapbox-gl'`
3. Just open the page with chrome

### Link to Demonstration

Can't provide a JSBin since it needs to be installed as an npm package. I basically just followed your quickstart documentation [here](https://docs.mapbox.com/mapbox-gl-js/overview/#quickstart) with the module bundler option

### Expected Behavior

When loading the page, there should be no error in the console and the library could be used normally as stated in the docs.

### Actual Behavior

When loading the page, I get the error described above.

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 quickstart module-bundler steps in Chrome using the import shown in the issue, then inspect the published dist/mapbox-gl.js entry and its exports. Done means the documented import loads without the default-export error and the library can be used normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.