#Circular dependency with barrel exports.

11 messages · Page 1 of 1 (latest)

modern ferry
#

With barrel exports, you should follow this simple rule and it should be mostly okay:

  • Only import files from barrel that are not also included in the barrel. That is, import stuff from barrels only outside the current folder. Never import stuff from barrel in the same folder.

Unless you have actual circular dependencies, barrels should not be an issue.

simple raft
whole tulip
#

@modern ferry I was following that rule, which you can see in code that I provide. I use barrel files only when I need to import something from outside module

lofty matrix
#

which you can see in code that I provide
Could be somewhere else by accident, and we'd have no way to know

#

If you can provide access to your code we could help you verify it.

#

Also note that 10.1.3 was just released which helps with some circular dependency resolution

whole tulip
#

@lofty matrix I already wrote that I can't provide rest of the code. I will try to upgrade nestjs version. Im currently on v.9. Thanks

lofty matrix
#

You can use tools like nestjs-spelunker or madge to help find the circular imports as well 🙂

whole tulip
#

@lofty matrix already tried them and none of them indicates that I have circular dependencies

lofty matrix
#

Well, without access to the repo, or a minimum reperoduction, we'll be just as in the dark as you

whole tulip
#

Yep I know, I will try to reproduce error on some dummy repo