Skip to content

Instantly share code, notes, and snippets.

@Gozala
Created December 4, 2009 15:16
Show Gist options
  • Save Gozala/249062 to your computer and use it in GitHub Desktop.
Save Gozala/249062 to your computer and use it in GitHub Desktop.
{
manifest: {
/*
overrides module sub path, most commonly used pattern in packages.
Only paths on local file system can override dirs.
require("module://mypackage/foo") -> /path/to/mypackage/foo.js
*/
"module://mypackage/": {
location: "file:///path/to/mypackage/"
},
/*
overrides particular module path doesn't matters if any package
is handling this suburl or not single module overrides has priority,
in addition module is remote one in this example, but it's not
mandatory.
require("module://mypackage/remote-module") -> http://www.myhost.com/remote-module.js
*/
"module://mypackage/remote-module": {
location: "http://www.myhost.com/remote-module.js"
},
/*
package can register special handler whic will be responsible for resolving
suburls it overrides. handler represents module name and method represents
method name which will be called with one argument passed to the require.
most likely module:// uri will be overrided by a platform handler which will
route to the right module. handler returns string with absoulte path to the
file whcih can be local or remote.
*/
"module://handled-modules/": { // overriding using handler
handler: {
module: "module://mypackage/protocol-handler",
method: "handle"
}
},
/*
almost like handler but instead of returning absolute path returns
module source. Platform should take care of making module out of it
which will be returned by require. BTW whole protocol can be registered
like this.
*/
"loaded:": {
loader: {
module: "module://mypackage/module-loader",
method: "handle"
}
},
/*
Package can register more then one sub path. Dir paths can be overided
by locations inside zip files as well, which are either local or remote.
zip handlers most likely will be implemented by platfrom as a custom loader
or in some cases like in xulrunner / firefox they might work out of the box.
Platform might implement remote zip handler with local caching or withoit,
it's up to the platform itself. in this example jar: protocol handler is
provided by platfrom.
require("module://compressed/bar") -> lib/bar.js under //path/to/arch.zip
*/
"module://compressed/": {
location: "jar:file:///path/to/arch.zip!/lib/"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment