Titanium Documentation
  1. Titanium Documentation
  2. TIDOC-514

commonJS require with relative and absolute paths with Android and Iphone

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: None None
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Guides
    • Labels:
      None
    • Environment:

      Titanium 1.8 sdk

    • Customer Priority:
      Next Patch
    • Customers:

      Description

      Using require with a file that is located in a directory above, then trying to access a file under that directory works different in android then it does in iphone.

      using 1.8 SDK tested in simulator, android 2.2 emulator and devices running 2.2, 2.3

      taken from: http://wiki.commonjs.org/wiki/Modules/1.1, Point 4 under Module identifiers:
      Module identifiers may be "relative" or "top-level". A module identifier is "relative" if the first term is "." or "..".

      example: app.js
      ------------------------------
      var test = require('levelOne/levelOne');
      test.open();
      //works in both

      levelZero.js located in Resources folder, same as app.s
      ------------------------------
      exports.open = function(){
      Ti.UI.createWindow(

      { backgroundColor: '#AAAAAA' }

      ).open();

      levelOne.js located in levelOne Folder right above app.js
      ------------------------------
      //note that i would only have one of these running below at a time

      exports.open = function()

      {require('../levelZero')}

      ;
      //can't find the file in Iphone, can find it on Android

      exports.open = function()

      {require('levelZero')}

      ;
      //can't fine the file in Android, can find it on Iphone

        Activity

        Hide
        Ivan Skugor added a comment -

        Just to add ... expected behavior is that both cases works on both platforms.

        Show
        Ivan Skugor added a comment - Just to add ... expected behavior is that both cases works on both platforms.
        Hide
        Ivan Skugor added a comment -

        IMHO, this is not documentation issue because this issue violates CommonJS specification (and documenting that has no sense ). Both ways of requiring CommonJS module are valid by specification and should work on both platforms.

        Show
        Ivan Skugor added a comment - IMHO, this is not documentation issue because this issue violates CommonJS specification (and documenting that has no sense ). Both ways of requiring CommonJS module are valid by specification and should work on both platforms.
        Hide
        Stephen Tramer added a comment - - edited

        This is fixed for iOS with TIMOB-9524. Documentation should be OK.

        Show
        Stephen Tramer added a comment - - edited This is fixed for iOS with TIMOB-9524 . Documentation should be OK.
        Hide
        Arthur Evans added a comment -

        Require paths should work correctly in 3.0.

        Show
        Arthur Evans added a comment - Require paths should work correctly in 3.0.
        Hide
        Paul Hamilton added a comment -

        3.0? when is that going to be released

        Show
        Paul Hamilton added a comment - 3.0? when is that going to be released
        Hide
        Martin Guillon added a comment -

        @arthur i am having this problem on 3.1.0 master

        Show
        Martin Guillon added a comment - @arthur i am having this problem on 3.1.0 master

          People

          • Assignee:
            Arthur Evans
            Reporter:
            Paul Hamilton
          • Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: