Loader

Moduleejs
Definition class Loader
InheritanceLoader inherit Object
Specifiedejscript-2.5
StabilityPrototype.

CommonJS loader class.

This is public do assist dynamic loading of ejs.cjs so namespace qualification is not needed.


Properties

QualifiersPropertyTypeDescription
static initializers null
static mainId null
static signatures null

Loader Class Methods

QualifiersMethod
static load(id: String, path: Path, config = expression, codeReader: Function = null): Object
 Load a CommonJS module and return the exports object.
static register(id, fn): Function
 Register a CommonJS module initializer.
static require(id: String, config: Object = expression): Object
 Load a CommonJS module.
static setConfig(newConfig: Object): Void
 Set the configuration options hash for require to use.

Loader Instance Methods

(No own instance methods defined)

QualifiersMethod

Method Detail

static load(id: String, path: Path, config = expression, codeReader: Function = null): Object
Description
Load a CommonJS module and return the exports object. After the first load, the script module will be compiled and cached as a byte-code module. It will be recompiled if the script source is modified or missing.
Parameters
id: String Unique name of the module to load. The id may be a unique ID, an absolute path, relative path or a path fragment that is resolved relative to the App search path. Ids may or may not include a ".es" or ".js" extension.
path: Path Optional path to the physical file corresponding to the module. If the module source code has changed, it will be re-compiled and then cached.
codeReader: Function Optional function to provide script code to use instead of reading from the path. [default: null]
config null [default: expression]
Returns
A hash of exported properties.

static register(id, fn): Function
Description
Register a CommonJS module initializer.
Parameters
id Unique path ID for the module. This is typically a relative path to the module.
fn Module initialization function.
Returns
The function.

static require(id: String, config: Object = expression): Object
Description
Load a CommonJS module. The module is loaded only once unless it is modified. WARNING: this will not be supported in future releases as the Harmony loader will be supported instead.
Parameters
id: String Name of the module to load. The id may be an absolute path, relative path or a path fragment that is resolved relative to the App search path. Ids may or may not include a ".es" or ".js" extension.
config: Object null [default: expression]
Returns
A hash of exported properties `.

static setConfig(newConfig: Object): Void
Description
Set the configuration options hash for require to use. Loader uses the config.extensions field to determine the eligible file extensions to use when searching for modules.
Parameters
newConfig: Object Configuration options hash.