Fork me on GitHub
#shadow-cljs
<
2021-04-01
>
Stuart Campbell06:04:24

Hello, I’m fiddling around trying to use mapbox-gl in a cljs project and having some trouble – not sure if this is really a shadow-cljs thing or not. But I noticed the following: • I have mapbox-gl ^2.2.0 as a dependency in package.json • I have a :main build that targets :browser with an entrypoint like (ns mapbox-test.main :require [mapbox-gl]) • compilation (`npx shadow-cljs build main`) fails like this:

Closure compilation failed with 2 errors
--- node_modules/mapbox-gl/dist/mapbox-gl.js:33
This code cannot be converted from ES6. class expression that cannot be extracted
--- node_modules/mapbox-gl/dist/mapbox-gl.js:37
This code cannot be converted from ES6. class expression that cannot be extracted
• if I instead do npx shadow-cljs browser-repl then (require 'mapbox-gl), I see no errors. I guess I’m confused about (among other things) what the difference is between these two ways of requiring something.

thheller08:04:01

@stuart611 set :compiler-options {:output-feature-set :es6} or higher (`:es7, :es8, :es2019, :es2020`) in your build config. browser-repl defaults to :es-next-in (the most modern stuff)

thheller08:04:27

the default is :es5 and you are using code that cannot be converted lower

thheller08:04:11

basically the option controls in how old a browser you need to support

thheller08:04:23

:es8 is a good default nowadays unless you need to support IE11

Stuart Campbell16:04:12

Superb, thank you for the fix & explanation 🙂