I've been thinking about this problem lately as well. I think one solution might be to build your games for a well specified abstract machine. Then, you can just build an implementation of that machine for the web, and run the games on that.
The inspiration for the idea was SCUMM, and how we're able to play SCUMM games now with SCUMMVM.
The inspiration for the idea was SCUMM, and how we're able to play SCUMM games now with SCUMMVM.