Update modules registration function to allow usage of "current" cradle #4546
Replies: 2 comments 1 reply
-
The objective of a module is to be completely isolated from the core. It is suppose to represent a domain or feature that works autonomously. Eventually, you can inject some dependencies that would be required, but it is more dependencies such as a logger an event bus or things like that. What module are you working on? what is the purpose of the module that pushes you to want to share the entire core container? I ask to evaluate if what you are looking for wouldn't be a plugin instead for now Just for information, the fact that the container used by the module is containing everything was a bug and not a feature in shared mode, you can see the fix here , you can also think of the module as a micro service, and your micorservices don't usually share something from the outside. Let me know if that is clear. |
Beta Was this translation helpful? Give feedback.
-
not a specific module, it's "tenancy" tenant containers created on boot (scoped from existing root container), on request (after tenant is resolved by a middleware) appropriate tenant container is picked up in to a request object. I had to override a lot of things, and after medusa-extender lost compatibility even more things (admin and storefront too) |
Beta Was this translation helpful? Give feedback.
-
In a project I'm working on I'm heavily relying on awilix scopes, I manage them, add data to them, and I need "natural" scopes "cascade" and for scope I modified to be used on resolve for registrations with SCOPED Lifetime.
medusa/packages/modules-sdk/src/loaders/utils/load-internal.ts
Line 115 in 44a0d11
but here, currently all modules are restricted to use "local" scope (created from main container)
please add an option for module definition to use current cradle instead
Beta Was this translation helpful? Give feedback.
All reactions