Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Linear dependencies between imported modules become circular #65
I really like the possibility to import general purpose modules (Q, _, custom helpers, etc.) but I feel that I encountered an issue.
I expect to use these general purpose modules in my whole application so I would like to add both of these modules in my config:
The problem is that now,
In this example, as in many other situations I guess, I could simply copy the code required during the creation of the object to avoid any relation between my modules but I feel there must be a better option.
I would like to thank you again for this fantastic module and hope that this example can help to improve it. ;)
If I understand right you issue is Circular Dependencies in AMD / CommonJs modules. Good news, I think:
*If you really want to have circular dependencies (most times its best to avoid them), *:
Now, if you DONT want to have circular dependency, I now realize that the
There is no easy solution for this I fear, unless you a) can make a least one of them a standalone bundle ? But certainly this can be improved. or b) write a custom
If you could please make a github repo with simplistic skeleton of you problem, I will take a closer look.
Sorry, I was unavailable for few weeks and then it took me some time to gather the different files to set up the repo.
So, in my case I "DONT want to have circular dependency" so I wrote a resource-converter (it's the first time I tried, it's great !)
So, here is the repository which highlights my structure and my problem:
I also thought that a solution could be to enforce explicit
As a side note, circular dependencies are easily solved in CommonJS, if you use the given
So, if instead of reassigning
you do a
then you will NOT have a problem with circular deps. This should also work on the AMD / UMD urequire conversion.
Of course it doesn't work if you want to assign something other than an
referenced this issue
Mar 5, 2017
I've tested with https://github.com/Demurgos/urequire-imports-dependencies and it works like a charm - my tests on the repo are in a bad state and had no time to refactor them :-(
You're welcome @demurgos - there a better fix today with beta.31 - non-bundle dependencies (eg