nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.76k stars 7.64k forks source link

a module's providers are not exported by default #5558

Closed bojidaryovchev closed 4 years ago

bojidaryovchev commented 4 years ago

my package json: "@nestjs/common": "^7.0.0", "@nestjs/core": "^7.0.0", "@nestjs/jwt": "^7.1.0", "@nestjs/mongoose": "^7.0.2", "@nestjs/ng-universal": "^4.0.1", "@nestjs/passport": "^7.1.0", "@nestjs/platform-express": "^7.0.0",

I have the following scenario:

ModuleA({ providers: [ServiceA] })

ModuleB({ imports: [ModuleA] })

so I would expect to be able to access ServiceA inside ModuleB however that's not the case unless I explicitly declare ServiceA in the exports array of ModuleA

not totally sure if that is expected behavior or a bug, you decide

regards!

jmcdo29 commented 4 years ago

This is expected. Nest is all about encapsulation of the logic and will only expose the services in the exports array, as described in the documentation