Skip to content

Module Loader

Jason edited this page Jun 23, 2014 · 1 revision

Lazo leverages a custom module loader, which is referenced prefixing a module id or path with a l!.

define(['l!app/server/some_module', 'l!app/client/some_module'], function (m1, m2) {
    // on the client m1 will be null
    // on the server m2 will be null
});

The loader no-ops server modules on the client and vice versa on the server. Additionally, it makes attempts to resolve relative Node module paths to the application baseUrl in the event that they cannot be resolved in the standard fashion. The no-op and resolution logic is based on directory naming conventions, i.e., server, client, and node_modules. The loader will inspect both the module ID and path for these directories.

It is best practice to always use the loader regardless of whether code is shared between the client and the server.