-
Notifications
You must be signed in to change notification settings - Fork 304
Komodo 9 Require
Todd Whiteman edited this page May 5, 2014
·
5 revisions
Komodo 9 introduces the require('module')
function (CommonJS specification) to be able to load JavaScript files on demand.
Example:
var logging = require("ko/logging");
Add-ons can define their own require names by adding a special require-path xpcom category entry into their chrome.manifest file:
category require-path commando chrome://commando/content/js/
and then they make use of their JS modules like so:
var proj = require("commando/project");
which would map to the chrome://commando/content/js/project.js file.
Komodo's require functionality is built on top of the Mozilla Addon SDK, so nearly all of the APIs defined there can be used inside of Komodo. I say nearly, as some things are obviously different (e.g. the Firefox browser has web page tabs).