Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4826] module.exports not supported when requiring a file

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-11-10T14:18:40.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sRelease 1.8.0.1
ComponentsiOS
Labelsn/a
ReporterRick Blalock
AssigneeBlain Hamon
Created2011-07-28T19:20:43.000+0000
Updated2011-12-07T16:01:57.000+0000

Description

module.exports is not supported in our require implementation. module is undefined.

Comments

  1. Bill Dawson 2011-10-05

    FYI, module.exports is not part of CommonJS. It is supported by Node's implementation of modules, and perhaps by a few other implementations (not Rhino, for example). The CommonJS [module spec](http://wiki.commonjs.org/wiki/Modules/1.1.1) explicitly states "modules must use the "exports" object as the *only* means of exporting." They're speaking there of the "free variable" exports, not module.exports. This suggests that using something called module.exports to export your API is, in fact, "illegal". :) NodeJS does it anyway. In the spec's discussion of the module variable, no reference to an exports property is ever made. (For more of my long-winded arguments, see TIMOB-5406 :) ) [This discussion](http://groups.google.com/group/commonjs/browse_thread/thread/f994b609460355e3) on the official commonjs mailing list makes it clear that it's a Node thing and that the CommonJS spec folks are by no means unanimous in wanting to adopt it. I'm not opposed to supporting it, btw. Just want to make it clear it's not part of the spec and that it will need to be done with parity in mind, because Android uses Rhino's implementation of require() and it is *not* supported therein.
  2. Reggie Seagraves 2011-10-27

    http://wiki.commonjs.org/wiki/Modules/1.1#Related_Discussion
  3. Blain Hamon 2011-11-07

    Hours recorded on 4825. Pull pending. https://github.com/appcelerator/titanium_mobile/pull/647
  4. Wilson Luu 2011-12-07

    Closing bug. Verified fix on KS > Platform > Common JS using the following environment: OS: Mac OS X Lion Titanium Studio, build: 1.0.7.201112061404 SDK build: 1.8.0.1.v20111207151125 Device: iphone 4S Sprint (5.0.1)

JSON Source