jorendorff / js-loaders

Pseudoimplementation of the proposed ES6 module loaders.
54 stars 7 forks source link

$ParseModule + $ModuleRequest -> $ParseModuleRequests? #57

Open johnjbarton opened 10 years ago

johnjbarton commented 10 years ago

From tracuer's point of view it looks like the Loader(options) callback list is missing some calls: these look like operations the compiler should perform:

           let body = $ParseModule(loader, load.source, load.name, load.address);

            //>     2.  Set the [[Body]] field of load to body.
            load.body = body;

            //>     3.  Set the [[Kind]] field of load to **declarative**.
            load.kind = "declarative";

            //>     4.  Let depsList be the ModuleRequests of body.
            depsList = $ModuleRequests(body);

I'm confused by this model. To me the Loader is about loading: it delegates parsing so I expected a callback taking a load and returning a depList, a callback on par with normalize and friends. load.body would be an opaque object set by the parseModule hook and used by loader.evaluate() hook. That is, the Loader does not get into the compiler's data structures.

In any case I don't see any reason that we need two operations since this is the only code using either.