Consider removing the relative-URL distinction in import names #353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initially I thought it would be useful to keep the absolute- and relative-URL cases syntactically separated, since the relative URL case requires this extra base URL argument which may not be present in various hosts (unlike the browser where there is always an ambiently well-defined base URL). You might hope that absolute-vs-relative would be a simple grammatical distinction, like it is in the original URL RFCs, but it's not (Web reality is much more complicated), which is why I thought it would be nice just to make the distinction clear one level higher. However, one can always invoke the URL parser (say, as implemented by the JS
URL
constructor) with an empty base URL and see if it fails and apparently this is a common way to ask whether a URL is relative.Based on this realization from feedback from @rossberg in #276, this PR proposes to remove the distinction at the
importname
level, instead having all URLs just use theurl=<...>
case, subsuming and removing therelative-url=<...>
case. Note that component-model validation still doesn't require URL parsing (any UTF-8-encoded bytes are considered valid), so it's only once a host wants to actually fetch the URL that the string gets URL-parsed.That being said, I'd be curious if there are any other considerations for why it's useful to keep the two cases separate that I'm overlooking. My assumption is that this change doesn't impact ESM-integration (which only needs the continued distinction of
<plainname>
vs.<urlname>
), but @guybedford please check me on that.Practically speaking, since
relative-url=
s were shipped in 0.2, we'll probably want a deprecation window during which tools can (trivially) switch tourl=
. It's also possible that noone actually had time to start usingrelative-url=
. CC @macovedj, who may also have thoughts.