{ "id": "149429", "key": "TIMOB-19155", "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": "2020-05-19T15:18:43.000+0000", "created": "2015-07-03T06:44:09.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "issuelinks": [], "assignee": null, "updated": "2020-05-19T15:18:43.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": "13600", "name": "LiveView", "description": "Live preview of Titanium apps" } ], "description": "When the (compiled) {{app.js}} contains a named self executing function (e.g. to protect global scope) LiveView will break.\r\n\r\nh2. Example\r\n\r\n{code:javascript}\r\n(function hello() {\r\n Ti.UI.createWindow({\r\n backgroundColor: 'green'\r\n }).open();\r\n})();\r\n{code}\r\n\r\nh2. Error\r\n\r\n{code}\r\n[INFO] [LiveView] Error Evaluating app @ Line: 1\r\n[ERROR] SyntaxError: Unexpected identifier 'hello'\r\n[ERROR] File: app\r\n[ERROR] Line: 1\r\n[ERROR] SourceId: \r\n[ERROR] Backtrace:\r\n[ERROR] undefined\r\n{code}\r\n\r\nh2. Cause\r\nI tracked this back to LiveView's {{fileserver.js}} where it bind all global variables in {{app.js}} to {{Global._globalCtx}}:\r\nhttps://github.com/appcelerator/liveview/blob/master/lib/fserver.js#L298-L312\r\n\r\nBefore this part everything is OK, but after the code will end up as:\r\n\r\n{code:javascript}\r\n nction hello() {\r\n Ti.UI.createWindow({\r\n backgroundColor: 'green'\r\n }).open();\r\n})();\r\n{code}\r\n\r\nh2. Solution\r\nAs the comment in the LiveView code says there IS a better way to do this. An example could be [how I did this|https://github.com/FokkeZB/ti-proxy/commit/147aa34eccb383cf33ef9df11677d3be766b4abb] for [ti-proxy|https://github.com/FokkeZB/ti-proxy], the client-side transformer that [appc-liveviewer-app|https://github.com/appcelerator/appc-liveviewer-app/] uses.\r\n\r\nWe should consider using ti-proxy for LiveViewer as well, it already has more features then LiveViewer does, like serving new/changed assets, cleaning up events etc.", "attachment": [], "flagged": false, "summary": "LiveView: Breaks when app.js contains named self execution function", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "LiveView 1.1.0.1433362383", "comment": { "comments": [ { "id": "455502", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "I can no longer reproduce this on SDK 9.0.1.GA, we removed the munging of code we use to do via a regex in favour of operating on the AST via babel so I imagine that this got fixed with that", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2020-05-19T15:18:39.000+0000", "updated": "2020-05-19T15:18:39.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }