Replies: 5 comments 8 replies
-
My question would be: Why target ES5 at all? https://philipwalton.com/articles/the-state-of-es5-on-the-web/ |
Beta Was this translation helpful? Give feedback.
-
Thank you all for your input. I followed @littlespex suggestion and set the target to |
Beta Was this translation helpful? Give feedback.
-
Hello @dsilhavy , |
Beta Was this translation helpful? Give feedback.
-
Hi @dsilhavy, In my case, I support since chromium 53 with this Babel target configuration:
|
Beta Was this translation helpful? Give feedback.
-
Missed this until now: We're extremely catious with polyfills on TVs in BBC as we've seen pretty much every issue under the sun. Hence we don't use build/transpiled Dash.js. Instead we pull Dash.js source files directly and build them ourself. Our final build is transpiled to target ES5, and we aim to avoid using language features from later versions unless the benfits far outweighs the cost. For example we've been using Promises for years. We make use of TypeScript's transpilation to enable writing modern(ish) syntax. |
Beta Was this translation helpful? Give feedback.
-
Description
In our current build process, we are using webpack as a module bundler and Babel to transpile code to a specific JavaScript version. In this thread, I would like to discuss which Babel target we should be aiming for. Our current base configuration looks like this:
However, this will not lead to valid ES5 code when checking with
npx es5-validator dash.all.min.js
:[es5-validator] Your code is not ES5 Compatible. It's not ready to ship to production, otherwise it will break you App on Android 4+ or iOS 8+.
As an example, the nullish-coalescing-operator is not transpiled with these settings.
When removing the
targets
option, Babel does the following:While this ensures the highest compatibility it increases the bundle size. As an example:
dash.all.min.js
withtargets: 'defaults'
: Size: 929KB, ES5 validator: faildash.all.min.js
with notargets
option: Size: 1100KB, ES5 validator: successQuestion
As described above, there is a tradeoff between bundle size and compatibility. I would like to understand if people have an opinion regarding which setting to choose.
Links
Beta Was this translation helpful? Give feedback.
All reactions