{ "id": "171146", "key": "TIMOB-25790", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "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": [], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-08-15T11:09:58.000+0000", "created": "2018-02-20T15:33:35.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": "High", "id": "2" }, "labels": [], "versions": [ { "id": "19957", "description": "", "name": "Release 7.1.0", "archived": false, "released": true, "releaseDate": "2018-03-14" }, { "id": "20099", "name": "Release 7.2.0", "archived": false, "released": true, "releaseDate": "2018-06-14" } ], "issuelinks": [ { "id": "56596", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171771", "key": "TISTUD-9085", "fields": { "summary": "Update to liveview 1.2.2 to support babel transpilation", "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": "None", "id": "6" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "updated": "2018-08-15T11:10:04.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": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" }, { "id": "13600", "name": "LiveView", "description": "Live preview of Titanium apps" } ], "description": "h5.Description\r\n\r\nUsing liveview with the {{}} flag in the tiapp set to true (or not in the tiapp as it defaults to true) currently throws the below error [link to source|https://github.com/appcelerator/liveview/blob/713d920a19f9a6b9a444f3de53d92118ad1439f3/build/liveview.js#L427]\r\n\r\n- This occurs because the liveview code is attempting to overwrite the global.L variable, globals are defined as readOnly [see here|https://github.com/appcelerator/titanium_mobile/blob/5ce893c20d97b8d62b100d331fa40c88744df2f2/iphone/Classes/KrollContext.m#L1101] and as all code in now run in strict mode this is now an error (credit to TIMOB-18465 for helping me figure this one out)\r\n\r\nThere's two ways we can fix this\r\n\r\n1. Remove kTiPropertyAttributeReadOnly on global properties\r\n2. Stop making all JS core run in strict mode by default by adding {{modules: false}} to the object passed to preset-env, which will have a knock on effect to ES6 module support\r\n\r\nMy vote goes for 1, but again this highlights the fact the transpilation step *_is going to cause breaking changes for people_*\r\n\r\n{code}\r\n[ERROR] Script Error {\r\n[ERROR] column = 12;\r\n[ERROR] line = 427;\r\n[ERROR] message = \"Attempted to assign to readonly property.\";\r\n[ERROR] sourceURL = \"file:///Users/eharris/Library/Developer/CoreSimulator/Devices/19A348C6-7F86-4096-AEDE-90BB291BC971/data/Containers/Bundle/Application/D00FE479-9C4B-4ECD-84B6-1C1790C822FE/ticreateapp.app/app.js\";\r\n[ERROR] }\r\n{code}\r\n\r\nh5.Steps to reproduce\r\n\r\n# Enable transpilation by adding the {{true}} flag to your tiapp.xml\r\n# Build an app using liveview to iOS\r\n\r\n\r\nh5.Actual\r\n\r\nError above is thrown\r\n\r\nh5.Expected\r\n\r\nNo error thrown, liveview should work as normal", "attachment": [], "flagged": false, "summary": "iOS: Liveview broken when transpiling code", "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": "Ti SDK: 7.2.0.v20180219091800, 7.1.0.v20180219033455\r\niOS 11 .1 simulator", "closedSprints": [ { "id": 126, "state": "closed", "name": "2018 Sprint 05 SDK", "startDate": "2018-02-25T19:38:08.926Z", "endDate": "2018-03-11T18:38:00.000Z", "completeDate": "2018-03-11T22:06:01.520Z", "originBoardId": 100 } ], "comment": { "comments": [ { "id": "434650", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "cc [~cwilliams] [~hknoechel] \r\n\r\nIf we take option 1 I think we should also fix this on all properties? Pier also filed TIMOB-18475 for String. properties, would probably be sensible to check what's globals are writable on all platforms and align for parity\r\n\r\nI should also note that I've done both options and they both work", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-02-20T15:37:49.000+0000", "updated": "2018-02-20T15:48:27.000+0000" }, { "id": "434651", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "So, I think there's still a way to \"fix\" liveview to hack the L function in a way that doesn't try to assign to the global \"L\" function: It appears to hijack require itself, and in that it can simply pass a reference to \"L\" that invokes it's own override (right here: https://github.com/appcelerator/liveview/blob/713d920a19f9a6b9a444f3de53d92118ad1439f3/build/liveview.js#L733). That does mean user code could insist on the original L function versus a possibly patched one:\r\n{code:javascript}\r\nglobal.L('my string'); // will always invoke the original method\r\nL('my string'); may invoke the overriden live view version\r\n{code}\r\nI mean this is effectively how it is passing along it's hacked require function, so I don't see why we couldn't do the same for the L override.\r\n\r\nI guess this raises a couple larger points:\r\n- Yes, transpilation could still break user code if they're doing very funky things like this that relied on non-strict behavior (i.e. actually overriding read-only globals!). In non-strict code though, wouldn't this hijacking of L actually silently fail? If the global L function is read-only non-strict code typically would silently ignore bad behavior and strict throws errors. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode\r\n- Do we want to open up some of our API to be non read-only? Clearly liveview has a use for overriding some builtin API members. But this is beginning to play with fire if we don't want some/all of our API to be read-only.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2018-02-20T17:04:58.000+0000", "updated": "2018-02-20T17:04:58.000+0000" }, { "id": "434656", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "I think one of the problems here is that we're not consistent across platforms, this code works on both Windows and Android (in strict mode) who allow global.L to be overwritten. iOS is the only platform which doesn't and the docs don't define it as read-only either. Looking at other globals in other environments node doesn't seem to complain when overriding in strict mode (from my fairly limited testing).\r\n\r\nI feel that, while this is fixable in liveview, given that (to my knowledge) we wouldn't be able ship the fix alongside 7.1.0 and that iOS is in the minority of how it behaves, we should be removing the {{kTiPropertyAttributeReadOnly}} on the global properties.", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-02-20T18:24:18.000+0000", "updated": "2018-02-20T18:24:18.000+0000" }, { "id": "434979", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Thought about it and agree with you [~cwilliams], I think parts of the global namespace should be read-only while others shouldn't (Ti/Titanium should be read-only for sure). Seeing as that's a problem for another day I've put up a fix for liveview, https://github.com/appcelerator/liveview/pull/109, tested across iOS and Android just need to test Windows", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-02-27T23:20:25.000+0000", "updated": "2018-02-27T23:20:25.000+0000" }, { "id": "435003", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Progressing to in review, have tested across Android, iOS and Windows and it works", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-02-28T15:58:56.000+0000", "updated": "2018-02-28T15:58:56.000+0000" }, { "id": "440799", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "This fix has now shipped in Studio 5.1.0 which was released yesterday. Please read the release blogpost for instructions on how to update, https://www.appcelerator.com/blog/2018/08/ga-release-appcelerator-studio-5-1-0/\r\n\r\nAs it's shipped I'm now closing this ticket", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2018-08-15T11:09:51.000+0000", "updated": "2018-08-15T11:09:51.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }