Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Support mapbox-gl 2.0 #108

@samanpwbb

Description

@samanpwbb

Out of the box, underreact does not support the latest version of mapbox-gl. Since underreact is often used by apps that use Mapbox, the two projects should be compatible. Read more about why mapbox-gl breaks here: mapbox/mapbox-gl-js#10173

The basic problem is related to transpiling gl js's worker code:

Babel correctly transpiles the inlined worker, however it relies on injecting a bunch of code into the global-scope which is a part of its runtime. Since the gl-js workers are inlined, build tools in the application (like studio) are not able to recognize this. This leaves the worker bundle with transpiled code, but missing global scope functions.

There are two possible fixes, documented here:

  1. Ignore transpiling GL JS
  2. Transpile GL JS, but use the external worker file.

I suggest option 1: It saves us bundle size and may also speed up time to first render (it's 31% lighter, saving 68kb). GL JS 2.0 does not support IE11 at all anymore, so transpiling for IE11 isn't serving any purpose. Option 1 is also what GL JS team recommends.

It looks like we could fix this by updating the exclude regex in getConfigForNodeModules:

exclude: /@babel(?:\/|\\{1,2})runtime/,

We could also consider supporting both options, but defaulting to 1.

@kepta would love your input. This issue has a little bit of urgency, as many frontend apps at Mapbox are going to be switching to 2.0 soon.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions