Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-23138

Parity: On Android require() tries current folder first

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 5.2.1
    • Fix Version/s: Release 6.0.0
    • Component/s: Android
    • Labels:
    • Story Points:
      5
    • Sprint:
      2016 Sprint 12 SDK

      Description

      Take the following app:

      Resources/app.js

      Ti.UI.createWindow().open();
      console.log(require('folder/foo').whoami);
      

      Resources/folder/foo.js

      exports.whoami = 'Resources/folder/foo.js';
      console.log(require('foo').whoami);
      

      Resources/foo.js

      exports.whoami = 'Resources/foo.js';
      

      On iOS the console will be:

      [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/app.js, Resource: app_js
      [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/folder/foo.js, Resource: folder/foo_js
      [DEBUG] Loading: /Users/fokkezb/Library/Developer/CoreSimulator/Devices/C7ECC4A2-E0F1-4248-B51E-5873696E719E/data/Containers/Bundle/Application/080A078B-81C0-4C7B-95FD-C994909390C0/req.app/foo.js, Resource: foo_js
      [INFO] Resources/foo.js
      [INFO] Resources/folder/foo.js
      

      While on Android it will be:

      [DEBUG] Module: Loading module: folder/foo -> Resources/folder/foo.js
      [INFO]  Resources/folder/foo.js
      [INFO]  Resources/folder/foo.js
      

      The documentation does mention that only on Android you can use absolute and relative paths, but it does not say that it will always try to resolve relative to the current directory first.

      I'd expect Android to work as iOS and not attempt to resolve relative to the current directory first.

      Ideally we'd resolve this as part of TIMOB-16078

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cwilliams Christopher Williams
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Chee Kiat Ng (Inactive)
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-9589
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration