jorendorff / js-loaders

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

duplicate mismatching .import calls #2

Closed dherman closed 11 years ago

dherman commented 11 years ago

What should happen when:

System.import("x", done, fail, {url: "x1.js"});
System.import("x", done, fail, {url: "x2.js"});

(Note the different urls.)

If we see the registry purely as a cache, we should really get two competing loads here, and whichever one finishes later gets an error... hmm. Perhaps a synchronous error on the second System.import() call would be better.

samth commented 11 years ago

The two different url fields don't meaningfully distinguish the two requests. In the same way that two syntactic import declarations from two different modules named "x1" and "x2" will get turned into one request, these two will become one request, even thought the referring url is different, and thus either both will succeed or both fail.

There is one way that these could be different, which is if the normalize hook for System produces different module names for these two, based on the url (or based on Math.random()).

samth commented 11 years ago

@dherman points out the the rest of the pipeline (after normalize) will see the referrer information from the first request (again, assuming that normalize produces the same thing for both calls).

jorendorff commented 11 years ago

Right, this makes perfect sense to me now. I wrote that comment before I understood what options.url was actually for. Bogus issue.