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. Given that main thread modules are rooted in resource://gre/modules/ and Jetpack modules are rooted in resource://gre/modules/commonjs/ I would like to place worker modules in resource://gre/modules/workers/ Any comments? Cheers, David -- David Rajchenbach-Teller, PhD Performance Team, Mozilla _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform