7. Narwhal
A CommonJS platform or implementation
Arguably the most mature implementation
Runs on several interpreters
Rhino has the most complete implementation
JavaScriptCore works well on Macs
Easy to add new engines if you're a language
implementation hacker
8. Why?
You can use it today
Rhino makes it easy to build off Java libraries
Lots of activity, and other implementations are
working to be compatible with it
But still needs lots of work
9. Narwhal packages
package.json
Based on the CommonJS local.json
bin/
package standard
lib/
tusk is a package manager foo.js
src/
sea is an environment manager jars/
packages/
Every project is a package engines/
tests/
foo.tests.js
10. package.json
{
"name": "jake",
"author": "Francisco Tolmasky <francisco@280north.com>",
"contributors": [
"Tom Robinson (http://tlrobinson.net/) <tom@280north.com>"
],
"description": "A build system for CommonJS, lifted from Rake",
"keywords": [
"build",
"jake",
"rake",
"make"
],
"version": "0.2.1"
}
11. Modules
Each JS file under lib/ is a module
Modules are executed within a function
Arguments are require, exports, and module
Modules return exports
Core concept of CommonJS