Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24610] Support ES6 by transpiling to ES5 via new tiapp.xml "transpile" property

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-01-29T15:48:55.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.1.0
Componentsn/a
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2017-04-20T18:36:01.000+0000
Updated2020-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.

Comments

  1. Christopher Williams 2017-04-26

    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?
  2. Ewan Harris 2017-05-08

    [~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
  3. Christopher Williams 2017-08-02

    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.
  4. Christopher Williams 2017-10-09

    WIP PR for 7.0: https://github.com/appcelerator/titanium_mobile/pull/9512
  5. Christopher Williams 2017-11-20

    https://github.com/appcelerator/titanium_mobile/pull/9512
  6. Gary Mathews 2018-01-28

    node-titanium-sdk: https://github.com/appcelerator/node-titanium-sdk/pull/20
  7. Gary Mathews 2018-01-28

    titanium_mobile_windows: https://github.com/appcelerator/titanium_mobile_windows/pull/1175
  8. Christopher Williams 2018-02-26

  9. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.
  10. Andrea Vitale 2018-11-30

    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:
        [ERROR] TypeError: promise.then(...).catch(...).finally is not a function
        

JSON Source