-
Notifications
You must be signed in to change notification settings - Fork 3
Support mapbox-gl 2.0 #108
Description
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:
- Ignore transpiling GL JS
- 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.