We have a big project with many files and we are starting to encounter cyclic dependencies. (where a file does a require do another file and the opposite).

Our file structure is: 1. place all the requirements in the top of the file 2. logic of the service 3. module exports the service.

When we run the code then it crashed because of the cyclic requirements.

But if we change the file structure to be: 1. logic of the service 2. module exports the service. 3. place all the requirements in the top of the file

then it seems to work well.

Is this solution dangerous?

0 Answers