Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2363] require() does not properly handle circular dependencies

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-03-28T21:06:57.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterSven Herzberg
AssigneeMauro Parra-Miranda
Created2013-03-28T16:15:18.000+0000
Updated2016-03-08T07:41:23.000+0000

Description

This (quite simple) project will not work with Titanium (and according to the docs at http://wiki.commonjs.org/wiki/Modules/1.1.1#Require it should, see point 3 over there):
// app.js
var first = require('first');
// first.js
var first = {
  name: 'first'
};

module.exports = first;

first.child = require('second');
// second.js
var second = {
  name: 'second'
};

module.exports = second;

second.child = require('first');
Please fix this.

Comments

  1. Carter Lathrop 2013-03-28

    Sven, I'm sorry but I can't seem to find where it says that this code should work for titanium. This wiki is for commonjs. Point three in this document shows: math.js
       exports.add = function() {
           var sum = 0, i = 0, args = arguments, l = args.length;
           while (i < l) {
               sum += args[i++];
           }
           return sum;
       };
       
    increment.js
       var add = require('math').add;
       exports.increment = function(val) {
           return add(val, 1);
       };
       
    program.js
       var inc = require('increment').increment;
       var a = 1;
       inc(a); // 2
        
       module.id == "program";
       
    this code will not work for Titanium as there is no UI declarations. May you please clarify? Thank you, Carter
  2. Mauro Parra-Miranda 2013-11-24

    Invalid issue.

JSON Source