JavaScript ES6 universal starter kit
github.com
github.com
RequireJS is really only good for AMD, but since AMD is rightfully dying in favor of CommonJS, I would use Webpack instead. There is some overhead compared to the AMDclean-ed version since it shims require(), though.
// hello.js
module.exports.hello = function() {
console.log("hello");
}
// test.js
var h = require('./hello');
h.hello();
The result of browserifying this is: (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports.hello = function() {
console.log("hello");
}
},{}],2:[function(require,module,exports){
var h = require('./hello');
h.hello();
},{"./hello":1}]},{},[2]);
It's pretty damn compact. Sure, every module is wrapped with the signature "function(require, module, exports)", but a good minifier such as Google Closure will reduce that by a lot: (function e$$0(d,b,f){function g(c,e){if(!b[c]){if(!d[c]){var a="function"==typeof require&&require;if(!e&&a)return a(c,!0);if(h)return h(c,!0);a=Error("Cannot find module '"+c+"'");throw a.code="MODULE_NOT_FOUND",a;}a=b[c]={exports:{}};d[c][0].call(a.exports,function(a){var b=d[c][1][a];return g(b?b:a)},a,a.exports,e$$0,d,b,f)}return b[c].exports}for(var h="function"==typeof require&&require,e=0;e<f.length;e++)g(f[e]);return g})({1:[function(k,d,b){d.exports.hello=function(){console.log("hello")}},
{}],2:[function(k,d,b){k("./hello").hello()},{"./hello":1}]},{},[2]);
I don't see what you win by going with RequireJS/AMD.