WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.65k stars 69 forks source link

base tag and importmap resolution #245

Closed timreichen closed 2 years ago

timreichen commented 3 years ago

How are paths resolved when both <base> tag and an importmap are present in an html file? Which is resolved first?

domenic commented 3 years ago

Nice question.

How it works is that all URLs in the import map, and all URL-like specifiers, are converted to absolute URLs first, using the <base> element. Then, the now-absolute URL-like specifiers are compared to the now-absolute URL-like specifiers in the import map.

Does this make sense? We can also walk through an example, if you have one, or you can check out the tests in https://github.com/web-platform-tests/wpt/tree/master/import-maps/data-driven/resources, e.g. https://github.com/web-platform-tests/wpt/blob/master/import-maps/data-driven/resources/url-specifiers.json is pretty informative.

timreichen commented 3 years ago

Thank you for your quick answer. This is what I assumed and what makes most sense to me. Maybe this information could be added to the readme somewhere?

domenic commented 3 years ago

Sure, a pull request would be welcome.