#How to implement a plugin which will expose module provider slot?

5 messages · Page 1 of 1 (latest)

midnight pilot
#

The documentation :
https://docs.medusajs.com/learn/configurations/medusa-config#register-modules-in-plugins
says:

When you register a plugin, its modules are automatically registered in the Medusa application. You don't have to register them manually in the modules configuration.

However, this isn't the case for module providers. If your plugin includes a module provider, you must register it in the modules configuration, referencing the module provider's path.

The example shows built-in plugin (notification) and possibility to include my own module.
My question is - is it possible to create my own plugin which will expose the slot for custom module of someone else?

Explore and learn how to use Medusa. Learn how to get started, the fundamental concepts, how to customize Medusa, and more.

faint tulip
#

yes they are normal modules, nothing that is internal only. Most of the work is in the module loader which reads the medusa config and instantiates providers in the module DI container(possibly with db sync).
I implemented my own custom provider module a while back but I didnt like how constrained providers are for my usecase(they have no access to the global container). It was very easy tho, I just copy pasted the notification module and did a bunch of renaming

#

the only minor gotcha is that since you have to register the provider, you have to resolve the module explicitly in your medusa config, and the module options override the options from the plugin section(if you have any) so keep that in mind, you might have to specify options twice

midnight pilot
#

thank you for the response! In other words - it is possible but not officially supported by Medusa (let's say)? The hint with checking notification module is great and that minor thing is acceptable for me - I can just put it in the README somewhere how to use it properly

faint tulip
#

yeah i asked for a guide a few weeks ago and they acknowledged it but i guess it's pretty low priority as it's kinda niche. might come in the future