Hello,
I recently decided to separate one of my node-red-contrib packages into two packages. I did this because some of the nodes were becoming redundant but offered a simpler method of usage.
My problem is that they both use the same config node to store an external API key and I would like for it to remain generic & common.
First attempt - wishful thinking
I tried adding the following checks before registering the node in both the .js and .html files but I was still getting warnings about an already registered node
if(!RED.nodes.registry.getNodeType("alpaca-config")){
RED.nodes.registerType('alpaca-config',{
//-----------------------node definition here
});
}
if(!RED.nodes.getType("alpaca-config")){
RED.nodes.registerType('alpaca-config',{
//-----------------------node definition here
});
}
I think it was the fact that "alpaca-config" was still defined in my package.json so I gave up on this approach.
Current solution - copy the dashboard nodes...
I realized this is a similar situation to the dashboard nodes, how there are separate packages that share the same group and tab nodes. Looking in there it seems that the "ui_group" is specified in node-red-dashboard and that all the peripheral packages call up ui_group from this package.
This is the approach I have taken and it works, but I would really like for a user to be able to pick one or the other package instead of requiring the primary package to be installed.
Possible solution - will this work?
I got to thinking, that maybe this problem can be solved with NPM. What if I separate out this configuration node into yet a third package and make it a dependency of both of my user-level packages, this should be a viable solution right? I guess my only question is will I need to register this config-level node with nodered.org or just publish it to npmjs? I see that nodered no longer automatically registers packages with the node-red tag so perhaps this is a use-case for that middle ground?
I know I could just try it out and see but I wanted to get some thoughts as I'm really out on a limb at this point.
Thanks for your time,
-Matt