{ "id": "168141", "key": "TIMOB-24811", "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": "2017-09-18T22:54:43.000+0000", "created": "2017-06-06T22:33:08.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "liveview", "titanium" ], "versions": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "issuelinks": [ { "id": "55882", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "outwardIssue": { "id": "169700", "key": "TIMOB-25231", "fields": { "summary": "Android: Ti.Filesystem.resourcesDirectory returns different list on device", "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": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "55727", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "outwardIssue": { "id": "169430", "key": "TISTUD-8840", "fields": { "summary": "LiveView: Include version 1.2.1", "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": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } }, { "id": "55883", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "169710", "key": "TIMOB-25241", "fields": { "summary": "Android: Ti.Network.createHTTPClient log 404 : Not Found error in application log", "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": "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": "2017-09-21T06:42:59.000+0000", "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" } }, "components": [], "description": "When requiring a module nodejs style, using index as default, requiring the same file using different paths results in different modules.\r\n\r\n_i.e. require('/test') vs require('/test/index')_\r\n\r\n*Steps to recreate:*\r\n\r\n1. Create a new Titanium app using the CLI\r\n2. Create a new file: /lib/test/index.js\r\n\r\n{code:java}\r\nvar test = {};\r\nmodule.exports = test;\r\ntest.x = 1;\r\n{code}\r\n\r\n3. Open the file controllers/index.js\r\n4. Add the following lines:\r\n\r\n{code:java}\r\nvar test = require('/test');\r\nconsole.error('test.x: ' + test.x);\r\n{code}\r\n\r\n5. Run app: appc ti build --platform ios --target simulator --log-level trace --liveview\r\n6. App should start successfully.\r\n7. The following should show in console log: {{test.x: 1}}\r\n8. Change the file: /lib/test/index.js\r\n\r\n{code:java}\r\nvar test = {};\r\nmodule.exports = test;\r\ntest.x = 2;\r\n{code}\r\n\r\n9. The following should show in console log: {{test.x: 2}} but instead the output is the same as before: {{test.x: 1}}\r\n\r\nIf you use the following in /controllers/index.js, it works as expected:\r\n\r\n{code:java}\r\nvar test = require('/test/index');\r\nconsole.error('test.x: ' + test.x);\r\n{code}\r\n\r\n\r\n*Another test that fails (and doesn't require a recompile or restart) is this:*\r\n\r\n\r\n{code:java}\r\nvar test1 = require('/test');\r\nconsole.log('test1.x: ' + test1.x);\r\ntest1.x = 2;\r\nvar test2 = require('/test/index');\r\nconsole.log('test2.x: ' + test2.x);\r\n{code}\r\n\r\nThe output of this with LiveView off is: \r\n\r\n{{test.x: 1}}\r\n{{test.x: 2}}\r\n\r\nBut with LiveView on, the output is this:\r\n\r\n{{test.x: 1}}\r\n{{test.x: 1}}", "attachment": [], "flagged": false, "summary": "LiveView causes multiple instances of same module when requiring using different paths", "creator": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "brentonhouse", "key": "brentonhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "environment": "iOS \r\nTI SDK: 6.1.0.GA\r\nAlloy: 1.10.2 \r\nJSCore - Enabled \r\nHyperloop: Not enabled\r\nLiveView: 1.1.0.1476939755\r\n\r\n", "closedSprints": [ { "id": 945, "state": "closed", "name": "2017 Sprint 18 Tooling", "startDate": "2017-08-27T21:14:41.095Z", "endDate": "2017-09-10T21:14:00.000Z", "completeDate": "2017-09-10T21:23:47.718Z", "originBoardId": 219 }, { "id": 931, "state": "closed", "name": "2017 Sprint 16 Tooling", "startDate": "2017-07-30T16:15:40.448Z", "endDate": "2017-08-13T16:15:00.000Z", "completeDate": "2017-08-13T23:07:49.237Z", "originBoardId": 219 } ], "comment": { "comments": [ { "id": "421914", "author": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "body": "This issue should be resolved using cached version of required module. In SDK 5.X.X the second call of require to the same module returns cached module.\r\n\r\nI'm sure that this will fix it:\r\n{code}\r\n- (TiModule *)loadAsFile:(NSString *)path withContext:(KrollContext *)kroll\r\n{\r\n\t// 1. If X is a file, load X as JavaScript text. STOP\r\n TiModule *module = nil;\r\n\tNSString *filename = path;\r\n module = [modules objectForKey:filename];\r\n if (module != nil) {\r\n return module;\r\n }\r\n\tNSString *data = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\t// If the file extension is .json, load as JavascriptObject!\r\n\t\tNSString *ext = [filename pathExtension];\r\n\t\tif (ext != nil && [ext isEqual:@\"json\"]) {\r\n\t\t\tmodule = [self loadJavascriptObject:data fromFile:filename withContext:context];\r\n\t\t}\r\n\t\tmodule = [self loadJavascriptText:data fromFile:filename withContext:context];\r\n\t}\r\n if (module != nil) {\r\n [modules setObject:module forKey:filename];\r\n return module;\r\n }\r\n\t// 2. If X.js is a file, load X.js as JavaScript text. STOP\r\n\tfilename = [path stringByAppendingString:@\".js\"];\r\n module = [modules objectForKey:filename];\r\n if (module != nil) {\r\n return module;\r\n }\r\n\tdata = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\tmodule = [self loadJavascriptText:data fromFile:filename withContext:context];\r\n\t}\r\n if (module != nil) {\r\n [modules setObject:module forKey:filename];\r\n return module;\r\n }\r\n\t// 3. If X.json is a file, parse X.json to a JavaScript Object. STOP\r\n\tfilename = [path stringByAppendingString:@\".json\"];\r\n module = [modules objectForKey:filename];\r\n if (module != nil) {\r\n return module;\r\n }\r\n\tdata = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\tmodule = [self loadJavascriptObject:data fromFile:filename withContext:context];\r\n\t}\r\n if (module != nil) {\r\n [modules setObject:module forKey:filename];\r\n return module;\r\n }\r\n\t// failed to load anything!\r\n\treturn nil;\r\n}\r\n\r\n- (TiModule *)loadAsDirectory:(NSString *)path withContext:(KrollContext *)kroll\r\n{\r\n\t// 1. If X/package.json is a file,\r\n TiModule *module = nil;\r\n\tNSString *filename = [path stringByAppendingPathComponent:@\"package.json\"];\r\n\tNSString *data = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\t// a. Parse X/package.json, and look for \"main\" field.\r\n\t\t// Just cheat and use TiUtils.jsonParse here, rather than loading the package.json as a JS object...\r\n\t\tNSDictionary *json = [TiUtils jsonParse:data];\r\n\t\tif (json != nil) {\r\n\t\t\tid main = [json objectForKey:@\"main\"];\r\n\t\t\tNSString *mainString = nil;\r\n\t\t\tif ([main isKindOfClass:[NSString class]]) {\r\n\t\t\t\tmainString = (NSString *)main;\r\n\t\t\t\t// b. let M = X + (json main field)\r\n\t\t\t\tNSString *m = [[path stringByAppendingPathComponent:mainString] stringByStandardizingPath];\r\n\t\t\t\t// c. LOAD_AS_FILE(M)\r\n\t\t\t\treturn [self loadAsFile:m withContext:context];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// 2. If X/index.js is a file, load X/index.js as JavaScript text. STOP\r\n\tfilename = [path stringByAppendingPathComponent:@\"index.js\"];\r\n module = [modules objectForKey:filename];\r\n if (module != nil) {\r\n return module;\r\n }\r\n\tdata = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\tmodule = [self loadJavascriptText:data fromFile:filename withContext:context];\r\n\t}\r\n if (module != nil) {\r\n [modules setObject:module forKey:filename];\r\n return module;\r\n } \r\n\t// 3. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP\r\n\tfilename = [path stringByAppendingPathComponent:@\"index.json\"];\r\n module = [modules objectForKey:filename];\r\n if (module != nil) {\r\n return module;\r\n }\r\n\tdata = [self loadFile:filename];\r\n\tif (data != nil) {\r\n\t\tmodule = [self loadJavascriptObject:data fromFile:filename withContext:context];\r\n\t}\r\n if (module != nil) {\r\n [modules setObject:module forKey:filename];\r\n return module;\r\n }\r\n\treturn nil;\r\n}\r\n{code}\r\n", "updateAuthor": { "name": "darknos", "key": "darknos", "displayName": "Sergey Nosenko", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2017-06-14T01:38:43.000+0000", "updated": "2017-06-14T01:38:43.000+0000" }, { "id": "426353", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "PR: https://github.com/appcelerator/liveview/pull/105", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-08-09T17:56:16.000+0000", "updated": "2017-08-09T17:56:16.000+0000" }, { "id": "427614", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "Fixed in liveview@1.2.1.", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-09-06T06:47:14.000+0000", "updated": "2017-09-06T06:47:14.000+0000" }, { "id": "427651", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "Update PR: https://github.com/appcelerator/liveview/pull/108", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-09-06T20:29:32.000+0000", "updated": "2017-09-06T20:29:32.000+0000" }, { "id": "428034", "author": { "name": "vvazquezmontero", "key": "vvazquezmontero", "displayName": "Victor Vazquez Montero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~fmiao]Hey Feon do we know when live view 1.2.1 will be released? ", "updateAuthor": { "name": "vvazquezmontero", "key": "vvazquezmontero", "displayName": "Victor Vazquez Montero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-09-18T18:24:55.000+0000", "updated": "2017-09-18T18:24:55.000+0000" }, { "id": "428058", "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-09-18T22:54:43.000+0000", "updated": "2017-09-18T22:54:43.000+0000" }, { "id": "428059", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "[~vvazquezmontero], it'll be shipped with Studio 4.10.0", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-09-18T22:55:18.000+0000", "updated": "2017-09-18T22:55:18.000+0000" }, { "id": "428060", "author": { "name": "vvazquezmontero", "key": "vvazquezmontero", "displayName": "Victor Vazquez Montero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thank you [~fmiao] do we have an expected ship that for that? ", "updateAuthor": { "name": "vvazquezmontero", "key": "vvazquezmontero", "displayName": "Victor Vazquez Montero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-09-18T22:58:46.000+0000", "updated": "2017-09-18T22:58:46.000+0000" }, { "id": "428061", "author": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "body": "[~kkolipaka] ^^", "updateAuthor": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "created": "2017-09-18T23:01:35.000+0000", "updated": "2017-09-18T23:01:35.000+0000" }, { "id": "428218", "author": { "name": "kkolipaka", "key": "kkolipaka", "displayName": "Kondal Kolipaka", "active": false, "timeZone": "America/Los_Angeles" }, "body": "[~vvazquezmontero] Studio 4.10.0 RC would be next week.", "updateAuthor": { "name": "kkolipaka", "key": "kkolipaka", "displayName": "Kondal Kolipaka", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-09-21T06:42:59.000+0000", "updated": "2017-09-21T06:42:59.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }