Feature
Support requiring based on relative paths:
- From sub contexts (a tab window with the url property set).
- As a result of Ti.include.
- From inside another require'd CommonJS module.
Platform Disparity
Require on Android deals with relative paths, just as described in
https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium#CommonJSModulesinTitanium-JavaScriptModulePathResolution. On iOS however, all Required files are searched for in the applications root.
Reproduction
Attached are several projects. The easiest to reproduce and quickest to grasp is "RelativePathingReducedReproduction.zip". Drop it in an app and run it. If you see any errors, then this isn't implemented yet. Otherwise, you should see three distinct Ti.API.info messages appear for each of the executed JavaScript files.
How can this be a duplicate of TIMOB-6689, a ticket which is closed because it is not reproducable. I provided code to reproduce the bug I encountered. Apparently you haven't take the effort to run my example. So what's the point of submitting bug reports if you close them unseen? Rather frustrating...
I'm pretty sure this is not fixed in 1.8.2 or 2.0.1GA. I also tried it as per the example in https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium#CommonJSModulesinTitanium-JavaScriptModulePathResolution. The CommonJS spec also says that the relative path is from the file that makes the "require" call and only absolute paths work where Resources is the root directory. I also confirmed it by running the same example through nodeJS as I'm trying to write re-usable javascript supported by both platforms. It would be great if someone could fix this in appcelerator. I've also zipped up the test case for someone to verify.
See attachment CommonJSTest.zip of relative path example to show that it's broken in 1.8.2 and 2.0.1GA and doesn't conform to the CommonJS spec: https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium#CommonJSModulesinTitanium-JavaScriptModulePathResolution
I have reproduced this with 2.1.0 and 2.0.3 builds. Please take another look. Also, if [TIMOB-6689] is not reproducible, but this is, then we have a different issue here, not a duplicate. Or we have a different test case that would merit [TIMOB-6689] being reopened. BROKEN with Ti SDK 2.1.0, timestamp=06/19/12 19:02, githash=da36a08 BROKEN with Ti SDK 2.0.3, timestamp=06/01/12 14:15, githash=a43004b
This should be fixed by TIMOB-9524. See pull request [2414](https://github.com/appcelerator/titanium_mobile/pull/2414).
Violates CommonJS 1.1 spec: http://wiki.commonjs.org/wiki/Modules/1.1 This is an issue which will be fixed on Android, not on other platforms (which behave correctly).
Closing ticket as invalid with reference to previous comments.