[TIMOB-24610] Support ES6 by transpiling to ES5 via new tiapp.xml "transpile" property
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-01-29T15:48:55.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.1.0 |
Components | n/a |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Christopher Williams |
Created | 2017-04-20T18:36:01.000+0000 |
Updated | 2020-01-28T15:17:42.000+0000 |
Description
Not all of our target platforms/OSes natively support ES6 code. So while we may be able to support "passing" ES6+ code through our tooling with TIMOB-24609, that raises an issue of users being able to write ES6/7 code that the JS engine doesn't yet support.
Given that we current support iOS 8 as minimum for Titanium 6 this makes this a pretty important feature.
As seen here: https://kangax.github.io/compat-table/es6/
- iOS 8 only supports roughly 17% of ES6 feature set. iOS 9 supports 54%; while iOS 10 is 100%.
- The issue is much less important on Android since we are currently on v8 5.1 which supports 97% of ES6.
- I'd have to research further for Windows, but I believe we're closer to an Android situation where virtually all of ES6 is supported.
There's some JSON files that give details on what browser support what features (basically the data behind the combat table above): https://github.com/kangax/compat-table?files=1 There's also a babel preset which basically filters the plugins used based on the "target" browsers/versions: https://github.com/sdkennedy/babel-preset-target Seems like pretty much exactly what we'd want, though maybe we'd need to run it once or twice to gather the list for our targets and then just generate our own non-dynamic preset?
[~cwilliams] Not sure whether you'd seen it but https://github.com/babel/babel-preset-env is probably the better preset as it's maintained by the babel team. Might be worth also seeing what they is happening in v7 of babel as I had heard they were thinking about moving preset-env into it by default
Of note here, is that we generate bad code using imports/exports on Alloy, and if we "fix" that issue there, we still need to handle import/export generally here. Safari 10.1 supports export natively, not sure if that means some versions of iOS's JSC does? We likely need to simply transpire import/exports into require via babel everywhere for now.
WIP PR for 7.0: https://github.com/appcelerator/titanium_mobile/pull/9512
https://github.com/appcelerator/titanium_mobile/pull/9512
node-titanium-sdk: https://github.com/appcelerator/node-titanium-sdk/pull/20
titanium_mobile_windows: https://github.com/appcelerator/titanium_mobile_windows/pull/1175
Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.
Guys, don't know if this is the correct jira issue but I have a feedback about ES6 and its Promises: _finally_ statement is only available for iOS. On Android it gives: