We use a monorepo (managed by Turborepo) to develop several independent NPM packages, that are shared across our services. For the sake of this question let's call them @company/module-a and @company/module-b.
When I import @company/module-a in my @company/app in the app.module.ts:
@module({
imports: [ModuleA]
})
It works. I can inject the services from ModuleA into my app and use them.
However, when ModuleA has a dependency on ModuleB like this: (module-a.module.ts)
@module({
imports: [ModuleB],
providers: [ModuleAService],
exports: [ModuleASerivce]
})
and the ModuleAService injects a service from ModuleB like this:
import { ModuleBService } from '@company/module-b'
@Injectable()
export class ModuleAService {
public constructor(private readonly moduleBService: ModuleBService) {}
}
the moduleBService is always undefined.
The Nest.js Injections seems not to be able to find ModuleBService. Not even when pointing it to it with:
public constructor(@Inject(ModuleBService.name) private readonly moduleBService: ModuleBService) {}
Then Nest.js throws an error, that it cannot find ModuleBService and if its module is correctly imported.
Is this a known bug? Are we doing something wrong here?