-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a note why module map uses request URLs #3624
Comments
This would be great to see, was also wondering recently why the response URL isn't used. If it's to do with interpretation, note that loading WASM will rely on "content-type" mime, so that the response is needed before further work in the loading algorithm can be done. |
That can't be it, since that's true for module JavaScript too. Only classic JavaScript ignores |
As a further suggestion here I was wondering if there aren’t deep technical limitations if we could specify a redirect using the |
Correction: I mean response URL of course. |
I'm not sure what that means. That when you hit a redirect with a flag set you'd update the module map? |
I guess it would require the same architecture change in coalescing
requests separately until their responses arrive, and then creating a
module map entry.
I guess I’m asking (a) is it too late to change to this behavior and (b) if
so, otherwise would it be possible to spec something like this as a
separate redirect code perhaps.
I still don’t see a strong technical reason why not though.
…On Sun, 15 Apr 2018 at 15:39, Anne van Kesteren ***@***.***> wrote:
I'm not sure what that means. That when you hit a redirect with a flag set
you'd update the module map?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3624 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAkiyudp4-zpIcL13lrF6s-2HXJ98EViks5to02CgaJpZM4TQKlE>
.
|
I'm still not sure what you mean by (b). Per CanIUse Chrome, Edge, and Safari have shipped, so I suspect revisiting it at this point would not be easy (and also, it would be incompatible with the shared workers architecture). cc @whatwg/modules |
We're not going to change this behavior, if only because of the consistency with other request-URL-based maps (image cache, shared worker cache, the as-yet-unspecified preload cache). But the reasoning is deeper than that. Consider the following module: import './a.mjs';
import './a.mjs'; If the module map was keyed on response URL, this would necessarily create two requests, since we don't know ahead of time which whether these two requests will end up at the same response URL. That's quite wasteful. Furthermore, the result becomes nondeterministic based on server behavior. You could then imagine adding some hack on top, e.g. storing the request URL but then switching to the response URL once the response comes in. Now you have a 2-to-1 mapping of keys to values, also bad. Plus you get more nondeterminism. And you're basically just reinventing the existing system, but in a more complicated and confusing way. There's also no value in using the response URL. Basically, having something different in the source specifier than actually used in the module map just creates a lot of confusion for no gain. |
I was under the impression that the specification process was supposed to be an open and transparent process where feedback and discussion around the intricacies of implementations was welcomed. Since the opinion here is already made, and I don't work at Google, it seems there's nothing more I can bring to this discussion. |
I see nothing in my comment that would lead to the kind of ad hominem message you have sent, @guybedford. Indeed, I tried to provide you with details on the intricacies of implementation and why and how we made the decision we did during the open and transparent process that took place during #433. I also have no idea why you are bringing Google into this. Perhaps if you wish to continue this discussion, it's best placed on whatwg/meta, so that we can continue to focus this thread on technical aspects (like the ones I explained in my post) and not ad hominem meta-critiques. |
@domenic I only want to discuss the arguments here, feasibility and use cases, this is what I am here to share. The first line of your response already states the outcome, and it is clear to both of us that is what it will be, regardless of those arguments, and from my experience in these discussions. Only a fool would keep arguing in such a situation. An open discussion is one in which you do not assume the outcome from the start. So yes, I'm appealing to the process itself to try to open up discussion again, as spec discussions should be. If you want to discuss this further, feel free to open a meta issue. As for the 2-1 key mapping, the response here is that browsers already coalesce requests based on URL and headers, and while I know this is a part of browsers that is perhaps under-specified, it seems like there's no reason the coalescing couldn't happen there using the module map after the response has been received. The definition of confusing in this context is somewhat subjective, and certainly something to be weighed up, but it doesn't seem infeasible. The use case is a version resolving module CDN - I request |
If Specifier resolution is via the response URL. Module map keys are via the request URL. They are unrelated, as noted already in the specification:
|
|
Indeed. If you refer to the same content by two different URLs in your program---whether that be one URL that redirects to the other, two different query strings, or simply two completely separate endpoints which your server happens to serve the same content for---the browser will treat those two URLs as separate. This holds for pretty much everything, including e.g. the request-keyed HTTP and service worker caches. |
I was somewhat bitten by this today: I made the mistake of assuming that a returning In my case I was assuming that because I was mapping from |
I tried to find the rationale in #443 why we picked request URLs in the module map (and not tried to wait for the response to come or some such) and couldn't find anything. It just states it as a fact.
Then later on there was #613, but that only talks about banning redirects, which was a non-starter.
It seems worth at least clarifying somewhere why we made this decision.
I guess the main reason is that deduplicating wouldn't work ahead-of-time so you end up with lots of fetches?
The text was updated successfully, but these errors were encountered: