Node-RED node installed as dependency requires restart

Huzzah, I think it works! Still requires a browser refresh, but that's much better than a restart.

I had found some code for loading dependencies (in loader.js - addModule()), but I never saw any output from this debug line:

log.debug(`Loading dependencies for ${module}`)

Digging further, in localfilesystem.js - convertModuleFileListToObject():

        if (moduleFile.package['node-red'].dependencies) {
            nodeList[moduleFile.package.name].dependencies = moduleFile.package['node-red'].dependencies;
        }

So node-red/dependencies, not the root (npm) dependencies.

From a 2017 comment in the backlog (Allow node modules to have node modules as dependencies · Issue #569 · node-red/node-red · GitHub):

Is there any way to declare node-red-node-dependencies.
Perhaps in the package.json. Something like this:

"dependencies": {
    "nodered-node-serialport": "^0.0.1"
},
"keywords": [ "node-red" ],
"node-red"     : {
    "nodes": {
        "sample": "sample/sample.js"
    },
    "dependencies": {
        "nodered-node-serialport": "^0.0.1"
    }
}

I'm guessing node-red/dependencies was just speculation at this point? Anyway, I found a reference to it in the docs for Packaging a Subflow as a module, confirming my understanding of the code from localfilesystem.js, and gave it a try. Found the commit for the dependency handling in loader.js - Handle subflow modules with their own npm dependencies. So the feature was added for a different use case, but unless there's plans to drastically alter (or remove) it, I guess it's OK to use it for this as well?

It would be nice if the dependency nodes were visible in the palette without a browser refresh, but that'll be a problem for another day.

Edit: added a couple of lines from the backlog comment