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

LiveView causes multiple instances of same module when requiring using different paths

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 6.1.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      iOS
      TI SDK: 6.1.0.GA
      Alloy: 1.10.2
      JSCore - Enabled
      Hyperloop: Not enabled
      LiveView: 1.1.0.1476939755

    • Sprint:
      2017 Sprint 16 Tooling, 2017 Sprint 18 Tooling

      Description

      When requiring a module nodejs style, using index as default, requiring the same file using different paths results in different modules.

      i.e. require('/test') vs require('/test/index')

      Steps to recreate:

      1. Create a new Titanium app using the CLI
      2. Create a new file: /lib/test/index.js

      var test = {};
      module.exports = test;
      test.x = 1;
      

      3. Open the file controllers/index.js
      4. Add the following lines:

      var test = require('/test');
      console.error('test.x: ' + test.x);
      

      5. Run app: appc ti build --platform ios --target simulator --log-level trace --liveview
      6. App should start successfully.
      7. The following should show in console log: test.x: 1
      8. Change the file: /lib/test/index.js

      var test = {};
      module.exports = test;
      test.x = 2;
      

      9. The following should show in console log: test.x: 2 but instead the output is the same as before: test.x: 1

      If you use the following in /controllers/index.js, it works as expected:

      var test = require('/test/index');
      console.error('test.x: ' + test.x);
      

      Another test that fails (and doesn't require a recompile or restart) is this:

      var test1 = require('/test');
      console.log('test1.x: ' + test1.x);
      test1.x = 2;
      var test2 = require('/test/index');
      console.log('test2.x: ' + test2.x);
      

      The output of this with LiveView off is:

      test.x: 1
      test.x: 2

      But with LiveView on, the output is this:

      test.x: 1
      test.x: 1

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmiao Feon Sua Xin Miao
                Reporter:
                brentonhouse Brenton House
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code