Skip to content

Commit 537121f

Browse files
authored
Update circular-dependency.md
was quite hard to find the issue here... Maybe it's good to add a warning about barrel files
1 parent 3eade68 commit 537121f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

content/fundamentals/circular-dependency.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ While circular dependencies should be avoided where possible, you can't always d
66

77
We also describe resolving circular dependencies between modules.
88

9+
> warning **Warning** A circular dependency might also be caused when using "barrel files"/index.ts files to group imports. Barrel files should be omitted when it comes to modules/providers. For more details please also see [this github issue](https://github.com/nestjs/nest/issues/1181#issuecomment-430197191).
10+
911
#### Forward reference
1012

1113
A **forward reference** allows Nest to reference classes which aren't yet defined using the `forwardRef()` utility function. For example, if `CatsService` and `CommonService` depend on each other, both sides of the relationship can use `@Inject()` and the `forwardRef()` utility to resolve the circular dependency. Otherwise Nest won't instantiate them because all of the essential metadata won't be available. Here's an example:

0 commit comments

Comments
 (0)