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:
- A dependency bundles its own copy of redi instead of declaring it as external
- Multiple versions of redi in your project
- Monorepo with inconsistent redi versions
Solutions:
- Ask dependency maintainers to set redi as external
- If a dependency re-exports redi APIs, use those instead of importing redi directly
- 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
undefinedwhen evaluated - Referencing a class before it’s defined
Solutions:
- Use
forwardRefto wrap the dependency:
import { Inject, forwardRef } from "@anthropic/redi";
class XXX {
constructor(@Inject(forwardRef(() => YYY)) private yyy: YYY) {}
}- Fix circular dependencies in your codebase. Use dpdm to find cycles.
Last updated on