One of the problems I'm running into when it comes to trying to integrate ES6 modules with HTML and new HTML-based dependency features is the way that I can't tell ES about dependencies I know about before the data is actually fetched and instantiated. The problem can essentially be summarised by this line from the definition of ProcessLoadDependencies():
# The ProcessLoadDependencies abstract operation is called after one # module has nearly finished loading. It starts new loads as needed to # load the module's dependencies. Suppose a page has this markup: <script type=module id=jquery href="jquery.js" whenneeded></script> <script type=module id=a href="a.js" uses="jquery" whenneeded></script> <script type=module> import "a"; // ... </script> ...where "uses" is some hypothetical markup for telling the browser about dependencies ahead of time (the assumption being that anims.js contains a line like 'import "jquery";'), and where "whenneeded" is some attribute that tells the browser to not bother starting the whole loading process until the resource is needed. In this example, the first two <script>s do nothing at first. Then the third one is parsed, PromiseOfStartLoadPartwayThrough() is called with the contents of the element as the source, and eventually the ES system learns that it wants module "a". Here, the "normalize" and "locate" hooks work together to determien that the element with id=a is what we're looking for. (Maybe it should be import "#a", to distinguish a package name from an ID, but that's a topic for another e-mail.) At this point, I want to tell the ES6 module that: (a) we need to set off a load for that second <script> element, and (b) once we have that <script> element's file, it's probably going to want to import "jquery", and therefore, we should also set off a load for that first <script> element with id=jquery. Right now, I don't see any way to do (b). ProcessLoadDependencies() is called after "instantiate" is done (by InstantiateSucceeded()), and it is the first time the ES6 module system tries to load anything. Ideally I think we should adjust the ES6 module system to support loading and compiling code (though not necessarily executing it) for dependencies at or around the "fetch" hook. Failing that, I guess we can also just do that at the HTML level. Will that just work? I'm not able to follow the ES spec closely enough to determine if, when ProcessLoadDependencies() is called for "a" and finds it needs "jquery", it will properly link to the as-yet-not-loaded-but- already-in-progress-load for "jquery". -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.' _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss