{ "id": "122087", "key": "TIMOB-15663", "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": null, "resolutiondate": null, "created": "2013-11-05T15:35:32.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "supportTeam" ], "versions": [], "issuelinks": [ { "id": "33098", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "122018", "key": "AC-2139", "fields": { "summary": "Module facebook is empty", "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" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": null, "updated": "2018-02-28T20:04:05.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h2. Problem description\r\nTrying to include the Facebook module inside a CommonJS module fails.\r\n\r\nh2. Code to reproduce\r\napp.js\r\n{code}\r\nvar fb = require('ui/facebook');\r\nfb.post();\r\n{code}\r\n\r\nui/facebook.js\r\n{code}\r\nexports.post = function() {\r\n\tvar fb = require('facebook');\r\n\tfb.appid = Ti.App.Properties.getString('ti.facebook.appid');\r\n\tfb.permissions = ['publish_stream'];\r\n\tfb.forceDialogAuth = true;\r\n\tfb.authorize();\r\n};\r\n{code}\r\n\r\nh2. Notes\r\nMoving the content of the function from ui/facebook.js to app.js solves the problem. The module is registered in tiapp.xml, as well as the property ti.facebook.appid.\r\n\r\nThe module is not defined; this means, the `authorize` method is invalid in the sample above.", "attachment": [], "flagged": false, "summary": "Android: Cannot require Facebook module inside a CommonJS module", "creator": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Android 4.3\r\nSDK 3.1.x, 3.2.0.GA", "comment": { "comments": [ { "id": "278168", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~dcassenti] How does it fail?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-05T16:28:33.000+0000", "updated": "2013-11-05T16:28:33.000+0000" }, { "id": "278418", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~ingo] I found out the reason why this is happening. Since the file where the facebook module is required is called `facebook.js`, the file which is actually loaded is the `ui/facebook.js` itself. Renaming it to something different solves the problem.\n\nHowever, in iOS it seems like the Facebook module has priority over the file in the same directory, so the code works fine.", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-11-06T14:11:46.000+0000", "updated": "2013-11-06T14:11:46.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }