#Module exporting itself

1 messages · Page 1 of 1 (latest)

cursive grove
#

If I have the following:

@Module({
    imports: [CqrsModule],
    providers: [Provider1, Provider2],
    exports: [CqrsModule, ModuleA],
})
export class ModuleA { }

and then I have:

@Module({
    imports: [ModuleA],
    providers: [Provider3],
    exports: [ModuleB],
})
export class ModuleB { }

Am I correctly assuming that ModuleB will have access to all the providers from ModuleA and CqrsModule? Will I have the same instances or do I have to manually export Provider1 and Provider2?

nimble lynx
#

You have to manually export the providers that are declared in the module that you want to export.

cursive grove
#

So there is no real reason to export the module itself in the decorator, right?

nimble lynx
#

Right

cursive grove
#

Thanks for the clarification 🙇‍♂️

silk parcel
#

Although that's something that you can do in Angular (AFIAK), It can cause circular dependencies issues
So I guess it's better to not have that feature in Nest