Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2824] iPhone commonjs modules shouldnt copy references out of exports

GitHub Issuen/a
ResolutionNeeds more info
Resolution Date2011-12-26T02:28:10.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
ReporterDunk Fordyce
AssigneePaul Dowsett


Values in exports in a commonjs module on iPhone appear to be copied to a new object. An example of this problem:
exports.my_overridable_function = function() {...} // replace this with your own functionality 
exports.do_stuff = function() { exports.my_overridable_function(foo); do_more_stuff_with(foo); return foo; };
var mymodule = require('mymodule');
mymodule.my_overridable_function = function() { ... };

// this wont call my function because the module object isnt the real exports object. 
This can be seen in the wild in http://documentcloud.github.com/backbone/#Sync - making it impossible (almost) to use this module with titanium_mobile. (I've got the feeling there are more bugs associated with this)


  1. Dunk Fordyce 2011-10-24

    commonjs modules test that this should pass https://github.com/commonjs/commonjs/tree/master/tests/modules/1.0/exactExports
  2. Shawn Lipscomb 2011-11-29

    I think this is another case of Titanium (under iOS) making copies of objects when they are assigned to variables, instead of making a reference to the object. Under Android, Titanium makes references like the Javascript spec says it should.
  3. Paul Dowsett 2011-12-26

    Dunk In order for me to escalate this to the core team, the test case must run without modification, as per the [Creating a Test Case](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase). Also, please check all the fields against the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist), and add any missing information. I will close this for now. Please reopen the ticket once it is complete, and I will move it to the main project. Thanks
  4. Paul Dowsett 2012-02-17

    Closing due to inactivity. If this issue still exists, please raise a new ticket, including all the information in the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist) to ensure that we can escalate it quickly. Read [How to Submit a Bug Report](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report) if you have not read it before, and always start a ticket using the [JIRA Ticket Template](https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template). Thanks in advance

JSON Source