I've been wanting to extend the client on my own for a while now, and I totally support the base concept. However I find the solution you're proposing here to be quite unadequate.
If you send this through module.exports, it will be interpreted by the server in some way, making it prone to error that'd stop your script, and use up some cpu even if so little, CPU.
Plus since the server is the one interpreting the main module, there's no telling it's even possible to send the interpreted code to the client (I highly doubt it).
The client will need to do some interpreting anyway; since it receives a copy of the code, you might as well do everything from the client, and not have the backend involved in the process in any way whatsoever :
The way I'd envision an "easy" client extension, there would be another sort of
main.js module, let's call it
client.js. For the server, it would be a module like every other: you don't include it anywhere in
main, and so it will never be run by the server; however, the client will seek this module, and run it like its very own main module.
From there all bet's open to define what we'll be able to do out of it, and how we would do it. That completely depends on the client's architecture.
Now we know this kind of thing could be possible, because some people already built there own custom clients; they totally have the power to achieve what you describe, and even more.
However I won't tell you to "just do that"; that would be a humongous task, I don't even have the time or will to do it myself, and I believe most people who'd try would only end up with a downgraded makeshift client rather than an enhanced one, which beats the whole point...
However one thing I would try myself at, is branch off the official client's and extending it into supporting this kind of feature. But to do that we would need to have the client's source code on hand.
(@ devs; We already have a github for the server's code, will we get something similar for the client? Please? I'm really looking forward to that.)