You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nib.js - Package CommonJS (Node.js) java/coffeescript libraries for the browser
nib.js is a library allowing to maintain javascript projects ala 'node.js' (CommonJS conventions
about modules, exports, require) while also targetting the web browser as execution platform. It
contains a simple packager command (nibjs) that will convert your sources to a single and
minified .js file to be embedded in the browser. Node.js's exports and require are correctly
resolved.
# if the sources are .js
nibjs --libname=mylib --output=dist/mylib.js lib
# if the sources are .coffee
nibjs --coffee --libname=mylib --output=dist/mylib.js lib
In the browser:
<script src="js/nibjs.js" type="text/javascript">
<script src="js/mylib.js" type="text/javascript">
<script>
// mylib contains what index.[js,coffee] exports
var mylib = NibJS.require('mylib')
</script>
<script src="js/mylib.js" type="text/coffeescript">
<script>
// NibJS is itself included in mylib.js
var mylib = NibJS.require('mylib')
</script>
See also
This project is related to CommonJS Module specification. In a sense, it is an offline
"compiler" implementation of the version 1.0 of that specification (not even complete).
I'll strongly consider any patch that would lead to respecting such specification more
completely!