I just installed it with 0.9.3 and it doesn't appear to work. It never created an es index, but search results were still coming back.
How plugins can communicate with each other?
If you, say, require a NodeBB plugin, it will fail because it looks for
module.parentto require things.
So, how can I build a plugin that can share functionality with other plugins and then use that plugin's functionality in other plugins?
Although not ideal you can require a plugin from node_modules. It might be better to put the plugin you depend on in your plugins package.json though so it is installed when your plugin is installed. Although I'm not sure if nested plugins like that are handled properly by the hook system.
@baris even if I rewire a plugin from node modules, it still looks for the NodeBB module.parent ime.
Yeah all the plugins assume they are required from src/plugins.js from core so that is kind of limiting. https://github.com/NodeBB/NodeBB/blob/master/src/plugins.js#L187
Add the other plugin as a peer dependency, fire custom hooks. That's how I did it.
Also another way I did was to use the socket namespace of the plugin in question. Because coincidentally I needed to execute those.
@pitaj Something to note is that if the plugin has already been required, subsequent requires will still have
module.parentpointing to the first module that required it.
So... when NodeBB starts and it requires
So if you only require the module after NodeBB is done with it (e.g. defer requiring until it is actually required), you might be ok.