I have about 10 ts files , in a Circular-Dependency-Hell .
The common methods can't help me any more , because the dependencies relation between 10 files is to complex.
At finally , I solved it. Using following 2 methods :
Install repo ———— "circular-dependency-plugin": "5.0.2"
This repo will helps me to find the place where circular occurs.
Using a designed internal.ts , to manage my import & export
I tried the method of this article :
How to fix nasty circular dependency issues once and for all in JavaScript & TypeScript
This amazing article tells me to create internal.ts .
and using like export * form 'file-A' ; export * from 'file-B'
to manage my circular dependencies.
It works very well when I use dependencies related to my 10 files, like this import classA from '../internal.ts'
.
————————————————————————————————————
If the above method has no effect on you, I found another general solution:
Use
const File_Promise = import ('yourFilePath')"
to import other file or module .
when you need to use this one, use
File_Promise.then (file => { file.xxx(file.yyy) })
, just like using Promise syntax.
`
This will break the Circular-Dep Chain !
If i am you , I will continue this action until NO ERROR Reported by "circular-dependency-plugin".
————————————————————————————————————
Hope to help YOU !