Open AlexeyKashintsev opened 8 years ago
Guys, I am actually dont know what kind of task can it be where such module structure can be handy. @AlexeyKashintsev , can you provide an example of such task? Cause I am completely confident that any task can be solved without recursive dependency.
Yes it's not quite common situation. But Platypus.JS have to handle such situation with normal work or by providing error message. Right now it just stops and do nothing.
Agree about error message in this kind of situations.
But still I am sure that using circular dependency is realy ugly practice in software design, so it must be avoided. Doesn't matter it is AMD or any other specification.
As an exception in some rare situations where this can't be avoided using some module in define()
dependency array argument is not really neccessary while require()
can be used any time. I think this can work fine. Try this, give us a note if this solution will work.
Can't disagree with @hcspidergrasp. Anyway it's not a question of architecture, it's only bug issue. And I've found that there is a little holy war by the topic ;) http://stackoverflow.com/questions/17146224/how-to-solve-circular-dependency-in-require-js http://stackoverflow.com/questions/4881059/how-to-handle-circular-dependencies-with-requirejs-amd ...
The problem with error message regarding circular dependencies is detection of such references. AMD format is asynchronous and so it is hard to detect such references. If you have such reference there nothing to examine to produce an error message. The system simply stops and it is all.
A developer can detect if his project contains circular references with a tool. For example madge from the stackoverflow post mentioned earlier.
@AlexeyKashintsev, looks like this holy wars caused by closeness of deadline when there is no time for rethinking of software design %)))
define('mod1', ['mod2'], ...);
define('mod2, ['mod1'], ...);
will fail to load without any exception. Added test for it . Look for platypus-tests pull request