jsx module system
commitbd90fcc15d504640a878667ecf2638d17628b44e
authorJohn Foerch <jjfoerch@earthlink.net>
Tue, 31 Jan 2012 00:18:30 +0000 (30 19:18 -0500)
committerJohn Foerch <jjfoerch@earthlink.net>
Tue, 31 Jan 2012 05:06:16 +0000 (31 00:06 -0500)
tree7d53ca003f2288c45f6a72e138ad95875b334cd6
parent37da0aed0b33973893ac909fc707d84ce7c3f170
jsx module system

This patch introduces a module system that works within the framework of
Conkeror's 'require' and 'load', makes no sacrifices in the way of
reloading modular code, and preserves our ability to write modules in
ordinary, idiomatic javascript.  It does this by introducing two
conventions: first, that Conkeror module files have the extension '.jsx';
and second, that the rest of the filename can be normalized to obtain the
module name.

By existing conventions, module filenames that have more than one word in
them use the hyphen as word separator.  The jsx module system translates
the hyphens to underscores to obtain the module name (since hyphen is not
allowed in js identifiers).  The 'feature-name' however, (the argument to
the 'provide' command), matches the filename, using hyphens, because
feature names are strings, not javascript identifiers.

When 'load' is called on a module spec (that is, a string that names a
module, or the relative path to a module) that does not have a file
extension, the search first tries the bare name as given with no
extension, then it tries it with the ".js" extension, and last it tries it
with the ".jsx" extension.
components/application.js
tests/simple/modules.js