Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9669] iOS: Relative Pathing of Require'd CommonJS Modules

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2012-07-12T16:16:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMark Ruys
AssigneeNeeraj Gupta
Created2012-01-20T11:59:28.000+0000
Updated2017-03-22T21:53:15.000+0000

Description

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.

Attachments

FileDateSize
CommonJsTest.zip2012-05-02T19:57:10.000+00002941139
RelativePathingReducedReproduction.zip2012-06-20T12:58:56.000+00003085
Resources.zip2012-01-20T11:59:28.000+00002312312

Comments

  1. Mauro Parra-Miranda 2012-02-21

  2. Mark Ruys 2012-02-21

    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...
  3. Quinn Mah 2012-05-02

    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.
  4. Quinn Mah 2012-05-02

    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
  5. Dawson Toth 2012-06-20

    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
  6. Stephen Tramer 2012-06-20

    This should be fixed by TIMOB-9524. See pull request [2414](https://github.com/appcelerator/titanium_mobile/pull/2414).
  7. Stephen Tramer 2012-07-12

    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).
  8. Lee Morris 2017-03-22

    Closing ticket as invalid with reference to previous comments.

JSON Source