shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Stuart Campbell 2021-04-01T06:10:24.302900Z

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.

thheller 2021-04-01T08:31:01.304Z

@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)

thheller 2021-04-01T08:31:27.304500Z

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

thheller 2021-04-01T08:32:11.305Z

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

thheller 2021-04-01T08:32:23.305300Z

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

Stuart Campbell 2021-04-01T16:00:12.306200Z

Superb, thank you for the fix & explanation 🙂