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.@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)
the default is :es5
and you are using code that cannot be converted lower
basically the option controls in how old a browser you need to support
:es8
is a good default nowadays unless you need to support IE11
Superb, thank you for the fix & explanation 🙂