Mongosh 0.10.0+ supports load() which seems to be exactly what you need. Please let me know if that is not what you had in mind.
Looks good to me.
AdminMassimiliano (Admin, MongoDB) commented
In `mongo`, you can call `load('/my/path/myscript.js')` and we are planning to support the same or a similar API in `mongosh`.
Is that close enough to what you are looking for?