Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#13454 closed enhancement (fixed)

async loader should warn when it sees a circular dependency to a module that does not also depend on 'exports'

Reported by: Colin Snover Owned by: Rawld Gill
Priority: high Milestone: 1.7
Component: Loader Version: 1.7.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

Right now if you accidentally create a circular dependency, one of the two modules ends up being defined as a blank object, and this can cause much confusion when debugging as I learned firsthand.

It would be good if the loader warned if this happens, with the exception that the warning should be suppressed if one of the modules also depends on 'exports' (which would indicate that the author is aware of the circular dependency and is working around it).

for example:

warn:

define('a', [ 'b' ], function () {
    return { foo: 'foo' };
});
define('b', [ 'a' ], function () {
    return { bar: 'bar' };
});

no warn:

define('a', [ 'b' ], function (b) {
    return { foo: 'foo' };
});
define('b', [ 'dojo', 'a', 'exports' ], function (dojo, a, exports) {
    return dojo.mixin(exports, { bar: 'bar' });
});

If it is too complex to do this suppression behaviour, just warning on all circular dependencies is probably better than the current behaviour of never warning and just returning a blank object.

Change History (3)

comment:1 Changed 8 years ago by Rawld Gill

Status: newassigned

comment:2 Changed 8 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

fixed in [25989]

comment:3 Changed 8 years ago by bill

Milestone: tbd1.7
Note: See TracTickets for help on using tickets.