smithmicro / mapbox-gl-circle

A *google.maps.Circle* replacement for Mapbox GL JS
https://smithmicro.github.io/mapbox-gl-circle/
ISC License
55 stars 26 forks source link

Cannot minify repo during Webpack build #60

Open ryanhamley opened 6 years ago

ryanhamley commented 6 years ago

Import repo: import MapboxCircle from 'mapbox-gl-circle';

Summary: Run Webpack to build the codebase with Webpack's UglifyJsPlugin on. Webpack is attempting to minify all the files in the codebase, but cannot handle ES6 code, resulting in an error.

Error: ERROR in <file>.js from UglifyJs Unexpected token: name (MapboxCircle)

Workaround: import MapboxCircle from 'mapbox-gl-circle/dist/mapbox-gl-circle.min.js'

Importing the minified file seems to be an acceptable workaround for the time being.

Solution: I don't believe this is limited to Webpack. I'm guessing any minification would result in this error. ES6 code could still cause errors in older browsers as well if not transpiled to ES5. It would be nice if the main file for importing was transpiled to ES5 so that it could be imported as mapbox-gl-circle; building and minifying would work well and unbuilt/unminified code could be assumed to work in older browsers.