After some more code digging and experiments I can answer my own question. A theme is a normal plugin and as such does not inherit any behavior from other plugins.
So you need to copy everything you need from the base theme library.js to your child theme. And of course, you need to declare client scripts explicitly.
Loading of missing templates from base theme is the only link between the base and the child theme.
Using a hook to pass variables between client and server
-
The best way is to use socket.io
You use socket.io to create an event in your server code like so,
// Require socket.io var socketPlugins = require.main.require('./src/socket.io/plugins') // Your plugin's app.load hook plugin.load = function (data, next) { // Create a socket namespace socketPlugins.yourplugin = {} // Create the event socketPlugins.yourplugin.eventname = function (socket, data, callback) { // The client will call this event to request data and optionally send its own data. // Use the callback to send the data it wants. First parameter is an error value. callback(null, {requestedinfo: 'I got the info'}) } next() }
In the client .js you call the event like so...
// The middle parameter is optional data you can send to the server. socket.emit('plugins.yourplugin.eventname', {}, function (err, data) { console.log(data.requestedinfo) })