-
Notifications
You must be signed in to change notification settings - Fork 304
Komodo 9 Require
Komodo 9 introduces the require('module')
function (CommonJS specification) to be able to load JavaScript files on demand.
Example:
var logging = require("ko/logging");
You can find available modules here: https://github.com/Komodo/KomodoEdit/tree/master/src/chrome/komodo/content/sdk
For example you can get the language of the current file:
var language = require("ko/editor").getLanguage();
Function getLanguage()
defined in editor.js
: https://github.com/Komodo/KomodoEdit/blob/master/src/chrome/komodo/content/sdk/editor.js#L604
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).