{ "id": "94315", "key": "TIMOB-9860", "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": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-07-16T11:04:29.000+0000", "created": "2012-07-02T14:13:04.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "SupportTeam", "core", "module_require", "parity", "qe-testadded" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [ { "id": "18276", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "93177", "key": "TIMOB-9524", "fields": { "summary": "iOS: Support multiple JS files per 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": "Medium", "id": "3" }, "issuetype": { "id": "5", "description": "The sub-task of the issue", "name": "Sub-task", "subtask": true } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-07-16T11:04:29.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" } ], "description": "h3. Problem\r\n\r\nThe javascript path argument for \"required\" with and without a slash in the beginning get treated as a whole new class.\r\n\r\nvar xyz1 = require ('/abc/xyz'); // gets loaded\r\nvar xyz2 = require ('/abc/xyz'); // won't loaded again\r\nvar xyz3 = require ('abc/xyz'); // will loaded again since the path doesn't start with a slash although it's pointing to the same javascript file.\r\n\r\nh3. Steps to Reproduce\r\n\r\nRun the sample code below and put a breakpoint or a debug statement to see the loading of require statement\r\n\r\n{noformat}\r\n// MyClass.js\r\nvar instance = null;\r\nexports.getInstance = function() {\r\n if (instance == null) {\r\n instance = new MyClass();\r\n }\r\n return instance;\r\n}\r\n{noformat}\r\n\r\n**app.js**\r\n\r\n{noformat}\r\n\r\nvar xyz1 = require('/MyClass');\r\n\r\nvar xyz2 = require('/MyClass');\r\n\r\nvar xyz3 = require('MyClass');\r\n\r\n{noformat}\r\n\r\nIf the file has been loaded already, the \"instance\" should NOT be null.\r\n\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "iOS: require ('abc/xyz') and require('/abc/xyz') get treated differently", "creator": { "name": "vjoshi", "key": "vjoshi", "displayName": "Varun Joshi", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "vjoshi", "key": "vjoshi", "displayName": "Varun Joshi", "active": true, "timeZone": "America/New_York" }, "environment": "Titanium SDK: 2.1.0.GA\r\nPlatform OS: iOS ver 5.1", "comment": { "comments": [ { "id": "201307", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "According to CommonJs specification, leading slash should not be present and it is not valid module id:\r\n\r\nhttp://wiki.commonjs.org/wiki/Modules/1.1\r\n\r\nLeading slash is working on some platforms in Titanium and many people use it, but nevertheless it shouldn't work because it's against specification. So, this issue is actually invalid.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-07-03T00:40:58.000+0000", "updated": "2012-07-03T00:40:58.000+0000" }, { "id": "201381", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Should be resolved by pull request for TIMOB-9524.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-03T13:04:26.000+0000", "updated": "2012-07-03T13:04:26.000+0000" }, { "id": "203231", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Pull#2414 merged.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-13T17:30:29.000+0000", "updated": "2012-07-13T17:30:29.000+0000" }, { "id": "207732", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Depending on the result of commonjs compliance this fix may be removed.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-16T11:00:06.000+0000", "updated": "2012-07-16T11:00:06.000+0000" }, { "id": "216968", "author": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Path with or without slash are not treated differently in require.\r\nVerified on:\r\nTitanium Studio: 2.1.2.201208281351\r\nTitanium SDK: 2.2.0.v20120828153312\r\niOS Simulator v5.1", "updateAuthor": { "name": "ssekhri", "key": "ssekhri", "displayName": "Satyam Sekhri", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-30T03:48:28.000+0000", "updated": "2012-08-30T03:48:28.000+0000" }, { "id": "261994", "author": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening to update label.", "updateAuthor": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-16T11:01:58.000+0000", "updated": "2013-07-16T11:01:58.000+0000" }, { "id": "261996", "author": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Updated label.\r\nVerified with:\r\n\r\nTitanium Studio:3.1.2.201307091843\r\nTitanium SDK: 3.1.2.v20130710144553\r\nacs:1.0.3\r\nalloy:1.1.3\r\nnpm:1.2.14\r\ntitanium:3.1.1\r\ntitanium-code-processor:1.0.1\r\nOS: OSX 10.8\r\nDevice: Galaxy Nexus (v4.0.4),iphone4(v5.1)\r\nXcode: 4.5.1\r\n\r\nPath with or without slash are not treated differently in require.", "updateAuthor": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-16T11:04:29.000+0000", "updated": "2013-07-16T11:04:29.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }