{ "id": "92562", "key": "TIMOB-9314", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" }, { "id": "13404", "description": "Sprint 2012-12 Core", "name": "Sprint 2012-12 Core", "archived": true, "released": true, "releaseDate": "2012-06-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-06-15T15:25:14.000+0000", "created": "2012-05-30T15:12:38.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "core" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "issuelinks": [], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-24T21:02:01.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": "10224", "name": "TiAPI", "description": "This component is used for cross-platform API work. Specifications are most likely to use this component." } ], "description": "This is the super task (specific iOS and Android sub-tasks exist).\r\n\r\nh3. Description\r\n\r\nCurrently, module projects for both Android and iOS have the option to put Javascript (rather than native) code in assets/[moduleid].js. If that file exists, then at build time the source is compiled/protected and, when distributed, the module is simply whatever is exported in that Javascript -- any code that happened to be on the native (*.m, *.java) files -- though compiled -- is ignored.\r\n\r\nFor example, when create either an iOS or Android module project, you get the .m and .java files for the module and a method named {{example}}. If you also add a commonjs module file in the form of assets/[moduleid].js, then that {{example}} method inside the native source file is _not_ reachable at runtime when the module is used.\r\n\r\nWe wish to make the optional CommonJS module file \"additive\" in the sense that it extends whatever is available via the native source, rather than replaces it.\r\n\r\nh3. Test Case\r\n\r\n* Create a module project for the platform you're testing (iOS or Android).\r\n\r\n* Create a file assets/moduleid.js (replace moduleid with the actual module id) and enter this code:\r\n\r\n{code:title=moduleid.js}\r\nexports.test = function() {return \"hello from inside the module's commonjs file\";};\r\n{code}\r\n\r\n* Build/package the module (./build.py for iOS, ant for Android.)\r\n\r\n* Create a Titanium Mobile app.\r\n\r\n* Install the module zip to the app (or up in the Titanium root). No instructions here -- it's assumed you know how to install a module.\r\n\r\n* Update tiapp.xml to include the module. (assuming you know how).\r\n\r\n* Put this in app.js:\r\n\r\n{code:title=app.js}\r\nvar m = require(\"moduleid\"); // replace moduleid with actual module id\r\nTi.API.info(m.test());\r\nTi.API.info(m.example());\r\n{code}\r\n\r\n* In the console/logcat, you should see info statements for \"hello from inside the module's commonjs file\" and \"hello world\".", "attachment": [], "flagged": false, "summary": "Native Module Projects (Android/iOS): At runtime, support execution of code originally from both CommonJS file and from native source files.", "creator": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [ { "id": "92563", "key": "TIMOB-9315", "fields": { "summary": "Android: External modules should support executing both a companion CommonJS file (if any) and the native code.", "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 } } }, { "id": "92564", "key": "TIMOB-9316", "fields": { "summary": "iOS: External modules should support executing both a companion CommonJS file (if any) and the native code.", "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 } } } ], "reporter": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Titanium 2.1.0", "comment": { "comments": [ { "id": "415775", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as fixed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T21:02:01.000+0000", "updated": "2017-03-24T21:02:01.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }