Affects Version/s: None
Fix Version/s: node-titanium-sdk 0.4.12
I'm making this a story because to me it's something that we need to investigate, discuss and act on
With the addition of babel in 7.1.0 users can now use new syntax in their applications without worrying about what their targets support. While that is the theory it's not the reality.
If you review Babels Learning ES2015 guide, some features denote Support via polyfill, this is because babel can only handle syntactical changes (arrow function to function expressions, let/const to var etc.), and for features such as maps and promises it is impossible to transpile these down so babel makes use of polyfills, which instead add these into the JS environment.
To me, there are a two avenues to us handling this
- We distribute babel-polyfill in the SDK
- We pass this on down to the user, either through usage of a module or just requiring them to add the module themselves.
- We evaluate including babel-runtime/transform-runtime in the transpile step https://babeljs.io/docs/plugins/transform-runtime
This has been attempted already (kind of) in two ways
- I attempted to add babel-polyfill to an app Hans Knöchel was writing (
TIMOB-25740), it didn't go well for me, I believe we could fix this
- Gary Mathews node-titanium-sdk PR, which includes regenerator-runtime to allow apps to use async/await
Here's my first thoughts on drawbacks I see with both ways
- User owned
- Doesn't adhere with our current way of handling this kind of thing where we deal with it
- SDK owned
- Unless we're detect what's needed every app will include it, whether they need it or not.
- We'll need to continually maintain this each release I believe
I looked at how others handle this, and discovered the following