Skip to Content

FAQ

”Loading scripts of redi more than once”

[redi]: You are loading scripts of redi more than once! This may cause undesired behavior in your application. Maybe your dependencies added redi as its dependency and bundled redi to its dist files. Or you import different versions of redi.

Common causes:

  1. A dependency bundles its own copy of redi instead of declaring it as external
  2. Multiple versions of redi in your project
  3. Monorepo with inconsistent redi versions

Solutions:

  1. Ask dependency maintainers to set redi as external
  2. If a dependency re-exports redi APIs, use those instead of importing redi directly
  3. Ensure consistent redi version across your monorepo

”Could not find dependency registered on”

[redi]: It seems that you register “undefined” as dependency on the X parameter of “XXX”. Please make sure that there is not cyclic dependency among your TypeScript files, or consider using “forwardRef”.

This happens when redi tries to register a dependency that evaluates to undefined.

Common causes:

  • Circular file dependencies causing a class to be undefined when evaluated
  • Referencing a class before it’s defined

Solutions:

  1. Use forwardRef to wrap the dependency:
import { Inject, forwardRef } from "@anthropic/redi"; class XXX { constructor(@Inject(forwardRef(() => YYY)) private yyy: YYY) {} }
  1. Fix circular dependencies in your codebase. Use dpdm  to find cycles.
Last updated on