You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using React.lazy madge still loads it as a circular module. Yes the file does depeend on it, but not on initial load so surely this should not count as a circular dependency as this is in fact the way to solve circular dependencies.
The components import routes.js to load the route to redirect to upon events (e.g. after login redirect to home), but the only import statement at the top of routes.js is importing React. The rest are imported with React.lazy and should surely not count when building the tree of circular dependencies.
The text was updated successfully, but these errors were encountered:
I was able to circumvent the problem by putting all Lazy import inside a specific file (LazyComponents.ts for instance) which exports everything, importing the relevant lazy components where needed, then excluding this file from Madge analysis.
So in your case, for instance, you could have a LazyComponents.ts:
The nice thing is that you have all your lazy components in one place, which is easier to manage the different chunks and such.
Of course, this only works and scale if you only put the Lazy components in this file. Nothing else should be defined here, since it won't be picked up by Madge.
When using
React.lazy
madge still loads it as a circular module. Yes the file does depeend on it, but not on initial load so surely this should not count as a circular dependency as this is in fact the way to solve circular dependencies.Consider the code below
Running
madge --circular ./src/index.js
returnsThe components import
routes.js
to load the route to redirect to upon events (e.g. after login redirect to home), but the only import statement at the top of routes.js is importing React. The rest are imported with React.lazy and should surely not count when building the tree of circular dependencies.The text was updated successfully, but these errors were encountered: