What is "cyclic module dependency" and how do I fix it?

I was looking around the TopbarPlus module, and I encountered a warning in the code called Cylic Module Dependency in a module script when I was requiring a different module script that’s a child of the module script I’m requiring it from.

If that sounds confusing, here’s a visual representation of what I mean:

Image of the warning:

I’m requiring the “IconController” Module script FROM the “Icon” Module Script
image


I have no idea what the code warning means, but there are 2 reasons I care about the warning:

  1. My OCD will makes me hate having any type of warnings or errors in my code
  2. It ruins Luau Autocomplete

Can someone explain what “cyclic module dependency” means, why it’s happening, and how I can fix it?

1 Like

Cyclic Module Dependency means the Modules use require on each other, causing an infinite loop. To fix this, you would have to change the setup of your Modules so that they don’t need to use require on each other.

1 Like

This manes that IconController and Icon are requiring each other, causing an infinite loop of being required.

1 Like