/browser.js

CommonJS-like modules in a browser

Primary LanguageJavaScriptMIT LicenseMIT

browser.js

example

index.html:

<!doctype html>
<html>
<head>
	<script src="/js/libs/browser.js" id="browserjs" data-base-url="/js/" data-main="app"></script>
</head>
<body></body>
</html>

js/app.js:

var a = require('./a');

console.log(a.func());

js/a.js:

var b = require('./b');

exports.func = function () {
	return b.func();
};

js/b.js:

exports.func = function () {
	return 'b.func';
};