{ "id": "171202", "key": "TIMOB-25816", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20205", "name": "node-titanium-sdk 0.4.12", "archived": false, "released": true, "releaseDate": "2018-06-18" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2019-03-04T19:10:45.000+0000", "created": "2018-02-26T23:15:29.000+0000", "epic": { "id": 152521, "key": "TIMOB-19834", "name": "Support ES6 for Titanium Application Development", "summary": "Support ES6 for Titanium Application Development", "color": { "key": "color_1" }, "done": false }, "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [ { "id": "56940", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171773", "key": "TIMOB-26117", "fields": { "summary": "iOS: ES6 promises not supported on iOS 9. (Works on iOS 8 and 10.)", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-03-04T19:10:50.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "h5.Description\r\n\r\n*I'm making this a story because to me it's something that we need to investigate, discuss and act on*\r\n\r\nWith 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. \r\n\r\nIf you review Babels [Learning ES2015|https://babeljs.io/learn-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.\r\n\r\nTo me, there are a two avenues to us handling this\r\n\r\n* We distribute [babel-polyfill|https://www.npmjs.com/package/babel-polyfill] in the SDK\r\n* We pass this on down to the user, either through usage of a module or just requiring them to add the module themselves.\r\n* We evaluate including babel-runtime/transform-runtime in the transpile step https://babeljs.io/docs/plugins/transform-runtime\r\n\r\nThis has been attempted already (kind of) in two ways\r\n\r\n* I attempted to add babel-polyfill to an app [~hknoechel] was writing (TIMOB-25740), it didn't go well for me, I believe we could fix this\r\n* [~gmathews] [node-titanium-sdk|https://github.com/appcelerator/node-titanium-sdk/pull/24] PR, which includes regenerator-runtime to allow apps to use async/await\r\n\r\nHere's my first thoughts on drawbacks I see with both ways\r\n\r\n* User owned\r\n** Doesn't adhere with our current way of handling this kind of thing where we deal with it\r\n\r\n* SDK owned\r\n** Unless we're detect what's needed every app will include it, whether they need it or not.\r\n** We'll need to continually maintain this each release I believe\r\n\r\nI looked at how others handle this, and discovered the following\r\n\r\n* react-native [rolls its own preset|https://github.com/facebook/react-native], which appears to be dynamic dependent on an apps usage. Polyfills look to be baked into react-native with them being defined when the [app start|https://github.com/facebook/react-native/blob/master/Libraries/Core/InitializeCore.js]", "attachment": [], "flagged": false, "summary": "Decide on best practices for polyfilling for ES6+ usage", "creator": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "subtasks": [], "reporter": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "environment": null, "comment": { "comments": [ { "id": "435052", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "I've had some luck with babel-polyfill on iOS after trying this again, I moved Hans' example to an async function for the geolocation https://github.com/ewanharris/titanium-es6-sample/tree/async_await. Android currently throws when requiring babel-polyfill, see TIMOB-25826.", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-03-01T12:56:43.000+0000", "updated": "2018-03-01T12:57:44.000+0000" }, { "id": "435727", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "*NOTE*\r\n- {{@babel/polyfill}} is used by {{ti.es6}} https://github.com/appcelerator/ti.es6/blob/master/plugins/ti.es6/1.1.0/hooks/ti.es6.js#L52\r\n", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-03-19T19:53:56.000+0000", "updated": "2018-03-19T19:53:56.000+0000" }, { "id": "438401", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "node-titanium-sdk: https://github.com/appcelerator/node-titanium-sdk/pull/32", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-13T21:07:43.000+0000", "updated": "2018-06-13T21:07:43.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }