Composition of Uncoordinated Working Sets of Modules

Kris Kowal kris.kowal at
Sun Jun 6 11:00:07 PDT 2010

Supposing that aQuery and bQuery are implemented by independent
uncoordinated authors.


    module $ {


    module $ {

If my interpretation is correct, these cannot be combined in a single

    <script type="harmony" src="aQuery.js"></script>
    <script type="harmony" src="bQuery.js"></script>

One solution to this problem is to convince A and B to coordinate,
which I've hitherto inferred was the only solution supported by Simple
Modules, in which case they share a fault with Java.

Is this a solution?

    <script type="harmony">
        module A_ = load("aQuery.js");
        module A = A_.$;
        module B_ = load("bQuery.js");
        module B = B_.$;

With this example, I am inferring that

* That the web-browser's loader knows the location of the current
  page, so it can resolve the MRL based on that location.
* "load" can only be used in the context of an importing module
* conceptually, if not at run-time, "load" returns a module instance
  that contains the top-level modules of the given script.
* that the top-level modules of the remote script are not registered
  as top-level modules of the local application, unlike co-DOM
* for a script to have importable bindings, these must exist in a
  module block of the loaded script.
* there is no notation for destructuring a module from a loaded
* a script is not a module, so exports cannot be used at the top

If that's the case, I would like to refine this approach, such that
loaded modules can have exports at the top level.  This would permit
the function export.


    export var $ = function () {


    export var $ = function () {


    module A = load("aQuery.js");
    module B = load("bQuery.js");

It would also be good for there to be a way to bind $ without binding
a module.

    const A = load("aQuery.js").$;
    const B = load("bQuery.js").$;

This obviously breaks a load call outside an import clause, which I
infer is not possible with the present proposal.

Is it possible to decouple name spaces from loaded modules?

Another point of interest is transitive loads.  I do not think that
there is a provision in the specification that would permit load
directives to be resolved relative to the location or MRL of the
module from which load call is declared.

    module Sazzle {

    module Sazzle_ = load("sazzle.js"); // relative to
                                    // "scripts/aQuery.js"
    module Sazzle = Sazzle_.Sazzle;
    module aQuery {
        export $ = function () {

    module aQuery_ = load("scripts/aQuery.js");
    const $ = aQuery_.aQuery.$;

Kris Kowal

More information about the es-discuss mailing list