Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMD recursive define fail #92

Open
AlexeyKashintsev opened this issue Jul 8, 2016 · 6 comments
Open

AMD recursive define fail #92

AlexeyKashintsev opened this issue Jul 8, 2016 · 6 comments

Comments

@AlexeyKashintsev
Copy link

define('mod1', ['mod2'], ...); define('mod2, ['mod1'], ...); will fail to load without any exception. Added test for it . Look for platypus-tests pull request

@valeriy-maslov
Copy link

valeriy-maslov commented Jul 9, 2016

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.

@AlexeyKashintsev
Copy link
Author

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.

@valeriy-maslov
Copy link

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.

@AlexeyKashintsev
Copy link
Author

AlexeyKashintsev commented Jul 13, 2016

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
...

@marat-gainullin
Copy link
Owner

marat-gainullin commented Jul 13, 2016

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.

@valeriy-maslov
Copy link

@AlexeyKashintsev, looks like this holy wars caused by closeness of deadline when there is no time for rethinking of software design %)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants