[AC-2824] iPhone commonjs modules shouldnt copy references out of exports
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Needs more info |
Resolution Date | 2011-12-26T02:28:10.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Dunk Fordyce |
Assignee | Paul Dowsett |
Created | 2011-10-24T03:33:34.000+0000 |
Updated | 2016-03-08T07:47:45.000+0000 |
Description
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.
mymodule.do_stuff();
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)
commonjs modules test that this should pass https://github.com/commonjs/commonjs/tree/master/tests/modules/1.0/exactExports
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.
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
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