On 5/18/2013 3:09 AM, David Rajchenbach-Teller wrote:
        Hi everyone,

   As part of the ongoing effort to make (Chrome) Workers useful for
platform refactorings, we have been working on a lightweight module
loader for workers (bug 872421). This loader implements a minimal
version of CommonJS modules, aka require.js.


Example:

// Setup the loader. We need this once per worker.
importScripts("resource://gre/modules/workers/loader.js");

// Import a few modules
let Logger = require("resource://gre/modules/workers/logger.js");
let Storage = require("resource://gre/modules/workers/storage.js");

// ...
// All values that are not exported are private to the module
// ...

exports.foo = function() { ... } // Export a value |foo|
exports.bar = 5; // Export a value |bar|



Once this loader lands, we will need some convention for where to place
modules for workers. Unfortunately, main thread modules (both .jsm and
Jetpack) can generally not be used by worker, due to different module
semantics, and more importantly due to the fact that most main thread
modules depend indirectly on XPCOM/XPConnect.

On the face of it it looks like it should be possible for Jetpack's module loader to load these worker modules. Is that something that seems desirable or are these modules not useful outside of workers?


_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to