cordova-js icon indicating copy to clipboard operation
cordova-js copied to clipboard

Run client-side JS through Babel

Open raphinesse opened this issue 6 years ago • 4 comments

Feature Request

Motivation Behind Feature

This would allow us to just set the environments we want to support in the Babel config and stop worrying about which JS features are supported by which version of which WebView.

Feature Description

As we have a build step anyways, so we would just have to add Babel to the build process.

The only real drawback I can see is that our generated cordova.js might not be as readable as before. But I'd be OK with that.

Real-life examples where not having this bit me: #203 #204

raphinesse avatar Jul 18 '19 16:07 raphinesse

I am also in favor of this idea. 👍

erisu avatar Jul 18 '19 16:07 erisu

I already have a running proof-of-concept. Will create a PR as soon as I find the time.

raphinesse avatar Jul 18 '19 20:07 raphinesse

If readability is a concern, we can also include source maps so that line numbers and stacktraces at least trace back to the original source file, which the web inspectors also supports and will display.

Not sure if the babel tool itself supports source maps cause I've always use babel in conjunction with another bundler like webpack.

breautek avatar Oct 10 '19 23:10 breautek

It supports source maps: https://babeljs.io/docs/en/options#sourcemaps

erisu avatar Oct 11 '19 00:10 erisu