{ "id": "165606", "key": "ALOY-1540", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "19384", "name": "alloy 1.9.11", "archived": false, "released": true, "releaseDate": "2017-04-10" } ], "resolution": null, "resolutiondate": null, "created": "2017-01-31T14:07:53.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [ { "id": "54201", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "165774", "key": "TIMOB-24373", "fields": { "summary": "npm node_modules are erroring out during build", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "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": "2019-09-05T15:59:17.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13604", "name": "Tooling", "description": "Items related to Alloy tooling and workflow" } ], "description": "I believe it was said that Ti SDK 6.0.0+ came with full node support. This should include installation of npm modules as well. Sadly, a lot of modules are not passing the compilation process of titanium, because they do not follow a certain convention.\r\n\r\nOne of those error messages would be:\r\n\r\n{code:javascript}\r\n[ERROR] Error generating AST for \"/Users/john/Documents/Appcelerator_Studio_Workspace/myapp/Resources/iphone/node_modules/glob/test/00-setup.js\"\r\n[ERROR] 'return' outside of function\r\n[ERROR] line 82, position 1779\r\n[ERROR] Alloy compiler failed\r\n{code}\r\n\r\nTestcase:\r\n\r\nCreate a package.json (regular npm setup) inside app/lib so the packages come available during runtime. Install for instance `mocha` (https://www.npmjs.com/package/mocha). There are many more packages that will fail the compilation process once installed into /app.\r\n\r\n`app/lib/package.json`\r\n\r\n{code:javascript}\r\n{\r\n \"name\": \"myapp\",\r\n \"description\": \"myapp\",\r\n \"private\": true,\r\n \"dependencies\": {\r\n },\r\n \"devDependencies\": {\r\n \"mocha\": \"2.5.3\",\r\n \"should\": \"7.1.1\",\r\n \"ti-mocha\": \"0.2.0\"\r\n }\r\n}\r\n\r\n{code}\r\n\r\nrun `npm install` in this directory to install the module.\r\n\r\nI recommend installing a lot of packages, and determine if they pass the Alloy compiler. Every compilation should pass.\r\n", "attachment": [], "flagged": false, "summary": "npm node_modules are erroring when compiling", "creator": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "environment": "Any (Tested on 6.0.1.GA)", "closedSprints": [ { "id": 864, "state": "closed", "name": "2017 Sprint 07 Tooling", "startDate": "2017-03-26T22:02:46.538Z", "endDate": "2017-04-09T22:02:00.000Z", "completeDate": "2017-04-10T15:38:31.332Z", "originBoardId": 199 } ], "comment": { "comments": [ { "id": "406022", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "[~hansknoechel], Alloy compile uses Uglifyjs to create ast of js files. For the reported error, {{'return' outside of function}}, it looks like an issue with Uglifyjs, which tries to be spec-compliant and does not like global scope returns. There could be other issues with uglify a commonJS module. I'm looking into this.\r\n\r\n[~cwilliams], it'll also be an issue with SDK uglifying npm modules files under {{/Resources}} dir TIMOB-24373.\r\n\r\n", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-02-01T03:29:56.000+0000", "updated": "2017-02-07T01:06:10.000+0000" }, { "id": "406029", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "PR: https://github.com/appcelerator/alloy/pull/814", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-02-01T09:23:49.000+0000", "updated": "2017-02-01T09:23:49.000+0000" }, { "id": "416743", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "The version of uglify-js that Alloy uses is a bit out-of-date. I'd be surprised if the new version tolerated {{return}} outside of functions. We had talks of changing the build process so that any Uglify exceptions would just be warnings and not stop the build, however in Alloy's case, I'm pretty sure it needs a valid AST to generate the app.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-04-04T15:14:15.000+0000", "updated": "2017-04-04T15:14:15.000+0000" }, { "id": "416825", "author": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "updateAuthor": { "name": "creative_jira_user", "key": "uzbbert", "displayName": "Creative", "active": false, "timeZone": "Europe/Amsterdam" }, "created": "2017-04-05T08:22:43.000+0000", "updated": "2017-04-05T08:22:43.000+0000" }, { "id": "416845", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "Alloy compile needs valid AST of controller to generate the app, it doesn't need to parse AST of the files in {{app/lib}}, they are copied to {{Resources}}. The question is does Alloy need to optimize all files under {{app/lib}} or {{app/lib/node_modules}}? Alloy can skip those files then we need to take care of TIMOB-24373.", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-04-05T15:35:29.000+0000", "updated": "2017-04-05T15:35:29.000+0000" }, { "id": "416847", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~uzbbert] That's a great find, however we use UglifyJS, not UglifyJS2, and UglifyJS doesn't appear to have this option. :(", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-04-05T15:43:57.000+0000", "updated": "2017-04-05T15:43:57.000+0000" }, { "id": "416848", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~fmiao] Alloy should never optimize anything in a node_modules directory.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2017-04-05T15:44:45.000+0000", "updated": "2017-04-05T15:44:45.000+0000" }, { "id": "417042", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "PR merged.", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-04-07T17:16:19.000+0000", "updated": "2017-04-07T17:16:19.000+0000" }, { "id": "451116", "author": { "name": "jkneen", "key": "jkneen", "displayName": "Jason Kneen", "active": false, "timeZone": "Africa/Ceuta" }, "body": "This is still an issue. Ti 8.1.1.GA, Alloy 1.14.0\r\n\r\n1. create new project\r\n2. create package.json in app/lib\r\n3. in *app/lib* do *npm install cryptlib* (for example)\r\n4. build the project\r\n\r\nFails with \r\n\r\n{{[ERROR] Alloy compiler failed}}\r\n\r\nDoing a trace log shows:\r\n\r\n{{[DEBUG] if (!process.env.SAUCE_KEY || !process.env.SAUCE_USER)\r\n[DEBUG] return console.log('SAUCE_KEY and/or SAUCE_USER not set, not running sauce tests')\r\n[DEBUG] if (!/v0\\.10/.test(process.version))\r\n[DEBUG] return console.log('Not Node v0.10.x, not running sauce tests')\r\n[DEBUG] require('./sauce.js')\r\n[DEBUG] \r\n[DEBUG] /Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/sourceMapper.js:212\r\n[DEBUG] throw e;\r\n[DEBUG] ^\r\n[DEBUG] SyntaxError: 'return' outside of function (4:2)}}", "updateAuthor": { "name": "jkneen", "key": "jkneen", "displayName": "Jason Kneen", "active": false, "timeZone": "Africa/Ceuta" }, "created": "2019-09-05T12:28:55.000+0000", "updated": "2019-09-05T12:28:55.000+0000" }, { "id": "451124", "author": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "I've created a PR that fixes this issue. If this is accepted as a feature for Alloy, I will create PR against Alloy master. \r\nhttps://github.com/brentonhouse/titanium-turbo/pull/52\r\n", "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2019-09-05T15:36:21.000+0000", "updated": "2019-09-05T15:36:21.000+0000" }, { "id": "451125", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~bhouse] I'm fine with always enabling {{allowReturnOutsideFunction: true}}. I get why it's a flag, but many, many projects explicitly enable this feature including Titanium: https://github.com/appcelerator/node-titanium-sdk/blob/master/lib/jsanalyze.js#L77-L83.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2019-09-05T15:44:32.000+0000", "updated": "2019-09-05T15:44:32.000+0000" }, { "id": "451129", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "I personally don't see a reason for a try/catch and I'd vote to have it removed from Titanium.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2019-09-05T15:59:17.000+0000", "updated": "2019-09-05T15:59:17.000+0000" } ], "maxResults": 15, "total": 15, "startAt": 0 } } }