{ "id": "83366", "key": "AC-2864", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-12-19T16:55:58.000+0000", "created": "2011-12-04T08:57:55.000+0000", "labels": [ "1.8.0.1", "android", "commonJS" ], "versions": [], "issuelinks": [], "assignee": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updated": "2016-03-08T07:47:48.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I have coded an app which includes specific control files in the app.js file. These use namesakes and anonymous functions. To avoid loading all files at runtime I then require using the commonJS method the files I need at the time a window is loaded.\r\n\r\nThe issue is that the namespace variables defined in the app.js included file are not found, it crashes with the namespace not being found.\r\n\r\nI have created a test case of this. Which works on IOS and Android using SDK 1.8.0. and the latest nightly build of 1.7.6 but not on previous versions of 1.7.6\r\n\r\nThere are 5 files but very little code in each one, I needed 5 as a minimum to show it working and failing.\r\n\r\nThe path structure can be seen in the app.js file, I have also created a git repository with the info in.\r\n\r\nhttps://github.com/thewarpedcoder/AndroidTestCase\r\n\r\nThanks\r\n\r\nT.\r\n", "attachment": [ { "id": "24459", "filename": "app.js", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T08:57:55.000+0000", "size": 569, "mimeType": "application/x-javascript" }, { "id": "24460", "filename": "ATCNS-CTL.js", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T08:57:55.000+0000", "size": 540, "mimeType": "application/x-javascript" }, { "id": "24461", "filename": "ATCNS-HELP-GlobalVariables.js", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T08:57:55.000+0000", "size": 186, "mimeType": "application/x-javascript" }, { "id": "24462", "filename": "ATCNS-VIEW-MainScreen.js", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T08:57:55.000+0000", "size": 568, "mimeType": "application/x-javascript" }, { "id": "24463", "filename": "ATCNS-VIEW-NextScreen.js", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T08:57:55.000+0000", "size": 545, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android: CommonJS required file not able to access global variables", "creator": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "environment": "* 1.8.0.1 nightly builds\r\n* engines: rhino and v8\r\n* all versions of ADK\r\n* Ti Studio 1.1.0.201112021759\r\n* Mac OSX Lion", "comment": { "comments": [ { "id": "174770", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Hi Trevor\r\n\r\nWould you mind reading TIMOB-6033, especially the comments by Rick and Marshall. We need to be certain that the issue you describe is not already covered in that one, before moving it across. Also, please see the guidance at [JIRA Ticket Checklist|http://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist] - for simple test cases, it's better to add code to the body of the ticket.\r\n\r\nCheers", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T10:22:05.000+0000", "updated": "2011-12-04T10:22:05.000+0000" }, { "id": "174776", "author": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "body": "Hi Paul.\r\n\r\nNot sure how I missed Marshalls comment. Obviously just skipped onto the next one. dyslexia again.. (well I am blaming it)\r\n\r\nOK my take on this. The 1.8.0 Sdk is potentially the one with the CommonJS bug in by allowing for global variables. 1.8.0.1 seems to have altered the implementation which is why my refactoring now does not work.\r\n\r\nI will have to look at this in greater detail in relation to this specific issue as Kevin has also used setters and getters for values. which is also a solution and would work really well in this scenario.. I will code a second test case where no Ti.includes are used at all, all that happens is namespaces are used to require the file into and then the current global variables are set using there own file, which is private and each has a setter and getter.\r\n\r\nThe issue I think is that I did not fully understand that even namespaces variables are being considered global. Which in fact they are.\r\n\r\nMy real issue now is that I use this method of populating a namespace with values To define static values like colours or fonts and sizes, and text so I only have one file which requires changing to change static values but these are also not being allowed going forward. I am not sure which SDK now has this bug in. \r\n\r\nThe TIMB-6033 Jira ticket is similar to this one, but is also different in that it specifically covers global variables being set and defined in required modules. I set them in the app.js by including the file which they are defined in and they are not then available, throughout the app as I would have hoped. Is this because I am implementing the static variables incorrectly. \r\n\r\nThis test case shows an example of a static value to be used throughout the app.\r\n\r\nI hope I have explained this ok, and am very happy if this is not a bug and 1.8.0 having the issue, but how would I then define a global static variable. Point well made and taken on setting and getting global values.\r\n\r\nAlso I have not raised many Jira tickets so please continue to point out the correct way to raise them hopefully I never get competent in them as this would mean I was raising way to many.\r\n\r\nThanks\r\n\r\nT.", "updateAuthor": { "name": "thewarpedcoder", "key": "thewarpedcoder", "displayName": "Trevor Ward", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-04T11:32:20.000+0000", "updated": "2011-12-04T11:32:20.000+0000" }, { "id": "176620", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Thanks for all the cooperation you have given with CommonJS, Trevor. As you have agreed with Kevin Whinnery, this behavior is by design, in line with the CommonJS spec. If you still believe it to be incorrect, please reopen.\r\n\r\nCheers", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-19T16:55:31.000+0000", "updated": "2011-12-19T16:55:31.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }