1) "Hey, how can I use the same code on the server and the client?" Hard problem, but you can look at Meteor or Derby for people working hard to solve it. It's unrelated to this project though.
2) "Hey, I've been using npm and require and coffeescript to write some cool code, but I want to run the entire thing in the browser. How can I somehow "bake" this all down to a single JS file I can deliver to the client where everything just works? This is a pretty easy problem, and it's been solved by Stitch (my favourite), Hem, Browserify, and probably a few more. And now, OneJS. :)
If it helps to see an example, I'm working on an app with a really big complicated source code tree; it's split into lots of files, plus a bunch of libraries, some of which are "traditional" JS libraries like jQuery, and some of which are "modern" CommonJS modules installed by npm. I use Stitch to bundle the whole thing into a single application.js file which contains every bit of my client-side code (only). My HTML file only contains two script blocks.
<script src="application.js"></script>
<script>
app = require('app');
$(function(){
app.run();
});
</script>
That's all it takes to load all my client side code - including all libraries - and then kick off the initialization code once the DOM is ready.I'm using Stitch, but I believe OneJS is designed to do the same thing. I'm afraid I find the documentation on the project really hard to follow though, so I might be wrong. :)