{ "id": "169857", "key": "TIMOB-25328", "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": [ { "id": "17609", "description": "", "name": "Release 7.0.0", "archived": false, "released": true, "releaseDate": "2017-12-07" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-11-16T18:30:40.000+0000", "created": "2017-09-21T11:03:50.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "cb-tooling", "regression" ], "versions": [], "issuelinks": [ { "id": "56127", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "169713", "key": "TIMOB-25455", "fields": { "summary": "Syntax eval is not working inside the CommonJS module.", "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": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "56128", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "inwardIssue": { "id": "167949", "key": "TIMOB-24884", "fields": { "summary": "CLI: Minification produces invalid code", "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": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "updated": "2018-08-06T17:49:21.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": "13103", "name": "CLI", "description": "Node-based command line interface" } ], "description": "When the app is installed on the device (also on Appstore) and the option *Enable Javascript Minification* is *active*, in some portions of the code there are some problems due to how the variables are minimized. So it depends on the structure of the code, in my case it's very complex, and i can't provide a sample code (for now).\r\n\r\nBut one case that i solved is this : \r\n{code}\r\nfunction myModule(..,...) {\r\n .....\r\n function test(){\r\n ......\r\n test2();\r\n function test2(){ ... }\r\n }\r\n \r\n}\r\nmodule.exports = myModule;\r\n{code}\r\nIn this case it was enough to do this for solve the problem\r\n{code}\r\nfunction myModule(..,...) {\r\n .....\r\n function test(){\r\n ......\r\n test2();\r\n \r\n }\r\n function test2(){ ... }\r\n \r\n}\r\nmodule.exports = myModule;\r\n{code}\r\n\r\nI have this problems with this SDK: \r\n- *6.2.1.G.A*\r\n- *6.2.0.G.A*\r\n- *6.1.2.G.A*\r\n- *6.1.1.G.A*\r\n\r\nI dont' have this problems with this SDK:\r\n- *6.1.0.G.A*\r\n- *6.0.4.G.A*\r\n- I didn't test the previous ones\r\n\r\nIf the option \"Enable Javascript Minification\" is not active there aren't problems.\r\n", "attachment": [], "flagged": false, "summary": "CLI: Option \"Enable Javascript Minification\" break code from SDK >= 6.1.1.G.A", "creator": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "subtasks": [], "reporter": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "environment": "Titanium SDK 6.0.4.G.A, 6.1.0.G.A, 6.1.1.G.A, 6.1.2.G.A, 6.2.0.G.A, 6.2.1.G.A", "comment": { "comments": [ { "id": "428244", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Very likely caused by TIMOB-24884, assigning to [~cbarber].", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-09-21T14:10:11.000+0000", "updated": "2017-09-21T14:10:11.000+0000" }, { "id": "428265", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "We use Babili to minify the code and it sometimes aggressively modifies the code as a result.\r\n\r\nI'm trying to reproduce this with master (7.0.0) and I can't seem to come up with a complex enough example that causes any issues.\r\n\r\nI wrote a small test, but it works as expected:\r\n\r\n{code}\r\nfunction test() {\r\n\tvar s = '';\r\n\tfor (var i = 0; i < 10; i++) {\r\n\t\ts += String(i);\r\n\t}\r\n\r\n\ttest2();\r\n\r\n\tfor (var i = 9; i >= 0; i--) {\r\n\t\ts += String(i);\r\n\t}\r\n\r\n\tfunction test2() {\r\n\t\tvar x = 0;\r\n\t\tx++;\r\n\r\n\t\ttest3();\r\n\r\n\t\tfunction test3() {\r\n\t\t\tconsole.log('hi from test3!');\r\n\t\t\tconsole.log(s);\r\n\t\t}\r\n\t}\r\n\r\n\ttest2();\r\n}\r\n\r\nmodule.exports = test;\r\n{code}\r\n\r\nIf you could provide a test case that can reproduce the issue, then I can take another look at this issue. Thanks!", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-09-21T16:48:49.000+0000", "updated": "2017-09-21T16:48:49.000+0000" }, { "id": "428309", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "body": "Can i try with [this|http://babeljs.io/repl/#?babili=true] ? \r\nPS: Something has changed from version *6.1.1.G.A* with the code minification? My code is always the same and the problems started with SDK 6.1.1.G.A.", "updateAuthor": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2017-09-22T07:00:58.000+0000", "updated": "2017-09-22T12:45:20.000+0000" }, { "id": "428474", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~nicolomonili] Yes, we replaced UglifyJS with Babili so that we can support ES2015 and newer in the tooling. ES2015 support in the JavaScript engines is a different matter.\r\n\r\nNow that we use Babili, it seems at times it's minification and dead code removal is super aggressive and we've had to scale it down, but there may be some edge cases that are problematic. If you have sample code that breaks, please let us know so that we can try to fix it. Perhaps our Babili version is out of date or something?", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-09-26T15:35:22.000+0000", "updated": "2017-09-26T15:35:22.000+0000" }, { "id": "428475", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "body": "In these days i try to reproduce the problem with a simplified example that i can post here.\r\nSorry, but i haven't yet understand if you have started to use Babili from the SDK 6.1.1.G.A (it is very important to know). Thank you", "updateAuthor": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2017-09-26T15:51:40.000+0000", "updated": "2017-09-26T15:51:40.000+0000" }, { "id": "428476", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Yes, it was 6.1.1, see [this PR|https://github.com/appcelerator/titanium_mobile/pull/9177] related to TIMOB-24884.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-09-26T15:55:45.000+0000", "updated": "2017-09-26T15:55:45.000+0000" }, { "id": "428478", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Babili was introduced via node-titanium-sdk in Titanium SDK 6.1.0.GA.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-09-26T16:01:32.000+0000", "updated": "2017-09-26T16:01:32.000+0000" }, { "id": "428606", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "body": "{quote}Appcelerator Studio, build: 4.9.1.201707200100\r\nAppcelerator SDK 6.2.2.GA\r\nNode.js Version = 4.6.0\r\nnpm Version = 2.15.9\r\nCLI Version = 5.0.4\r\nnode-appc Version = 0.2.31{quote}\r\n\r\nI was able to recreate the problem with this simple test. This code works only if it is not minified.\r\n\r\nFile *app.js*\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\nvar test = require(\"test\");\r\nwin.add(\r\n\tnew test()\r\n);\r\nwin.open();\r\n{code}\r\n\r\nFile *test.js*\r\n{code}\r\nfunction testModule() {\r\n\r\n var viewMain = Ti.UI.createView();\r\n\r\n var num = 0;\r\n var ins = 0;\r\n\r\n function function1(fff) {\r\n\r\n var vsp = fff.ppp.ddd[0].split(\";\");\r\n\r\n var vsp0 = vsp[0];\r\n\r\n\t\tins = 0;\r\n num = 0;\r\n\r\n if (ins == 0) {\r\n\r\n switch(num) {\r\n case 1 :\r\n if (fff.bbb(vsp0, 0) == 1) {\r\n \r\n } else {\r\n \r\n }\r\n break;\r\n }\r\n\r\n function2('1', null, null);\r\n\r\n for (var i = 0; i < 8; i++) {\r\n\t\t\t\tfunction2(null, \"val\" + i, i + 1);\r\n }\r\n \r\n function function2(_v1, _v2, _v3) {\r\n\r\n }\r\n\r\n } else {\r\n\r\n }\r\n\r\n };\r\n\r\n \tviewMain.animate({\r\n opacity : 1.0,\r\n duration : 500\r\n });\r\n \r\n\tfunction1(\r\n \t{\r\n \t\tppp : {\r\n \t\t\tddd : [\"1;2;3;4\"]\r\n \t\t},\r\n \t\tbbb : function(c1,c2){\r\n \t\t\treturn 0;\r\n \t\t}\r\n \t}\r\n );\r\n \r\n return viewMain;\r\n}\r\n\r\nmodule.exports = testModule;\r\n\r\n\r\n{code}\r\n", "updateAuthor": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2017-09-29T13:54:56.000+0000", "updated": "2017-10-02T06:50:41.000+0000" }, { "id": "428885", "author": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "body": "Are there updates on it? Thank you", "updateAuthor": { "name": "nicolomonili", "key": "nicolomonili", "displayName": "nicolomonili", "active": true, "timeZone": "Europe/Rome" }, "created": "2017-10-10T07:16:48.000+0000", "updated": "2017-10-10T07:16:48.000+0000" }, { "id": "430186", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "I get \\{\\{\\[ERROR] message = \"0 is not a function (evaluating 'c(\\\"1\\\",null,null)')\";}} with SDK 6.2.2. \r\nNo error with master (7.0.0.v20171104095810).", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-11-06T23:22:42.000+0000", "updated": "2017-11-06T23:22:42.000+0000" }, { "id": "430524", "author": { "name": "hrfn", "key": "hrfn", "displayName": "Hugo Ramos Freire Neto", "active": true, "timeZone": "America/Los_Angeles" }, "body": "My app is breaking on Iphone device when I require a specific minified file.\r\n\r\nTo reproduce:\r\n1. Create a new project\r\n2. add he.js on lib folder. (Link: https://github.com/mathiasbynens/he/blob/master/src/he.js)\r\n3. var he = require('he'); //on index.js\r\n4. Run on iphone device. (Not Simulator)\r\n5. The app should break with message: \"Invalid Character \\u8472 at hs.js (line 1)\"\r\n\r\nPS: Before SDK 6.1.x the he.js library works.\r\nPS2: If I run with --skip-js-minify flag everything works fine.\r\n", "updateAuthor": { "name": "hrfn", "key": "hrfn", "displayName": "Hugo Ramos Freire Neto", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-11-13T18:39:02.000+0000", "updated": "2017-11-13T18:39:02.000+0000" }, { "id": "430720", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hknoechel] The workaround is use {{--skip-js-minify}} from the CLI or uncheck the minify box from Studio. We will work on this now\r\n", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-11-15T16:41:05.000+0000", "updated": "2017-11-15T16:43:56.000+0000" }, { "id": "430739", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "So [~nicolomonili]'s example works fine on the latest master build for me. Looking between 6_2_X and master, we actually use babili 0.1.4 in both cases, but it looks like it picked up different plugins in each case, here are the changes:\r\n{code}\r\n \"babel-plugin-transform-member-expression-literals\": \"6.8.4\" -> \"6.8.5\"\r\n \"babel-plugin-transform-merge-sibling-variables\": \"6.8.5\" -> \"6.8.6\"\r\n \"babel-plugin-transform-minify-booleans\": \"6.8.2\" -> \"6.8.3\"\r\n \"babel-plugin-transform-property-literals\": \"6.8.4\" -> \"6.8.5\"\r\n \"babel-plugin-transform-remove-console\": \"6.8.4\" -> \"6.8.5\"\r\n \"babel-plugin-transform-remove-debugger\": \"6.8.4\" -> \"6.8.5\"\r\n \"babel-plugin-transform-simplify-comparison-operators\": \"6.8.4\" -> \"6.8.5\"\r\n \"babel-plugin-transform-undefined-to-void\": \"6.8.2\" -> \"6.8.3\"\r\n{code}\r\n\r\nSo the bug fix is apparently in there for his issue. Don't know if we want to back port to the 6.X branches or not, but master seems fine.\r\n\r\nFor [~hrfn]'s issue, I can reproduce on master using the v1.1.1 tarball release's he.js file from the linked repo. That file makes use of a lot of unicode characters and the minification tries to \"inline\" the unicode points from the escape sequence to the actual character and the JS engine chokes on u2118 (I assume it may choke on others). Technically any unicode character should be a valid source character in the ES6 spec, but in practice the JSCore engine may not like that. I really don't know the best way forward for this specific edge case. Technically the minifier (which is 3rd party) is doing the right thing - it's a bug in JSCore (Apple's JS engine in iOS/Safari). In this case, this specific file should not be minified, or the specific babel plugin which inlines the string values should be skipped (babel-plugin-minify-constant-folding) for it. I don't know how to offer that up to app developers easily.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2017-11-15T21:58:03.000+0000", "updated": "2017-11-15T21:58:03.000+0000" }, { "id": "430743", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "[~cwilliams], there's a fix for the [~hrfn]'s issue https://github.com/appcelerator/node-titanium-sdk/pull/17. \r\n", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-11-15T22:05:37.000+0000", "updated": "2017-11-15T22:05:37.000+0000" }, { "id": "430801", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "*Update*: Using the latest PR, it now works for all my test-cases! [~imarkovi] will confirm in the morning, but he already approved that the fix works for him as well. [~nicolomonili] You can also try the fix by replacing the \"jsanalyse.js\" from the PR above in your local SDK installation, e.g.:\r\n{code}\r\n~/Library/Application Support/Titanium/mobilesdk/osx/6.3.0.GA/node_modules/node-titanium-sdk/lib/\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-11-16T10:07:40.000+0000", "updated": "2017-11-16T10:07:40.000+0000" }, { "id": "430821", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Merged that PR, now here's the PR to include the updated module in the SDK: https://github.com/appcelerator/titanium_mobile/pull/9610", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2017-11-16T15:47:45.000+0000", "updated": "2017-11-16T15:47:45.000+0000" }, { "id": "430848", "author": { "name": "imarkovi", "key": "imarkovi", "displayName": "Ivan Markovic", "active": true, "timeZone": "Europe/London" }, "body": "Hans, yes it works! So, so pleased. Much appreciated. Thank you. ", "updateAuthor": { "name": "imarkovi", "key": "imarkovi", "displayName": "Ivan Markovic", "active": true, "timeZone": "Europe/London" }, "created": "2017-11-16T20:15:13.000+0000", "updated": "2017-11-16T20:15:13.000+0000" }, { "id": "431532", "author": { "name": "dieskim", "key": "dieskim", "displayName": "David van de Meer", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "dieskim", "key": "dieskim", "displayName": "David van de Meer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-11-30T15:03:39.000+0000", "updated": "2017-11-30T15:03:39.000+0000" }, { "id": "433175", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "In a big app I'm working on, we still have the problems even using 7.0.1 . Minification causes the following iOS issues:\r\n* if JSCore is enabled the app quits after a few seconds\r\n* if JSCore is not enabled, there is one controller which exhibits strange behaviour such as a line invoking Ti.Gesture.removeEventListener('orientationchange', someFunction) inside a function is executed when the controller is ran. Like if minification has detached the line from the function to which it belongs and placed it alongside the rest of the controller's code. If I comment out the line, the event listener stays.\r\n\r\nThe app is very complex, this controller is being created from within a complex chain of events. I'll try to isolate the issue and provide a test case.\r\n\r\nCompiling our app using a CLI > 6.2.4 causes the issue, with the controller. and I think CLI >6.1.x crashes if using JSCore \r\n\r\nEDIT:\r\nUsing CLI 6.3.0 to 7.0.1 and SDK 6.3.x , Ti.Gesture.addEventListener and Ti.Gesture.removeEventListener were not working after minification. SDK 7.0.1 solved that.\r\nThe issue of the app crashing a few seconds after boot if minification and JSCore were used was triggered by inline 'require' statements being executed during the first run loop. After assigning the exports object to variables the problem was averted.", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-16T09:47:01.000+0000", "updated": "2018-01-17T15:41:26.000+0000" }, { "id": "433254", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for the feedback [~rlustemberg]! [~fmiao] should we allow inline require statements or is this an intended babel behavior?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-17T16:06:34.000+0000", "updated": "2018-01-17T16:06:34.000+0000" }, { "id": "440127", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:49:21.000+0000", "updated": "2018-08-06T17:49:21.000+0000" } ], "maxResults": 24, "total": 24, "startAt": 0 } } }