JSBuild ensures that CommonJS modules can be used in browser-based applications
github.com
github.com
You either need a special loader, or you need to package the code into a wrapper.
The other bad part about it is that it is not async. Which means your code blocks whilst it loads. Loading code off a slow hard disk, or off the network? Blocked.
I'm not sure why they have made these design decisions.
CommonJS seems a step backwards to me.
And by using a loader (as you mentioned) these formats also work in browsers.
BTW It's possible to load CommonJS code asynchronously by splitting your built code into separate parts. You may be interested at the other project I'm working on, named DOMLoader (http://github.com/azer/domloader)
Regards
Of course you need a loader or packaging script, any module system that wants to handle dependencies will. Script tags are inadequate for anything except the simplest cases.
You can load your modules asynchronously, even though the main "require()" API is synchronous. Simply load the modules and their dependencies up front before executing them. This is what we've been doing for years in the Objective-J loader, and several CommonJS browser loaders already do it.
Also, I believe "require.async(id, callback)" is part of the spec now too, and they're working on an "async module definition" spec, which allows loading in script tags with minimal boilerplate ("require.def(id, function() { /module/ })")
Yabble does support unwrapped modules, so you might want to take a look at that: http://github.com/jbrantly/yabble
When compiling all it does it does is inline the files you have requir'd.