From 35db46c83c87e58d4bf0b8ac4a5e3e601ba9f7c1 Mon Sep 17 00:00:00 2001
From: Domenic Denicola fetching
". Module maps are used to ensure that imported JavaScript modules are
- only fetched, parsed, and evaluated once per Document
or worker.
Document
or worker.
+
+ Since module maps are keyed by URL, the following code will + create four separate entries in the module map, since it results in four different + URLs:
+ +import "https://example.com/module.js"; +import "https://example.com/module.js#map-buster"; +import "https://example.com/%6dodule.js"; +import "https://example.com/module.js?debug=true";+ +
That is, URL queries and fragments can be varied to create distinct entries in the + module map; they are not ignored. Similarly, no canonicalization beyond that + performed by the URL parser is applied, even if the same resource would be fetched from the server. Thus, four separate fetches and four + separate module evaluations will be performed.
+ +In contrast, the following code would only create a single entry in the module + map, since after applying the URL parser to these inputs, the resulting URL records are equal:
+ +import "https://example.com/module2.js"; +import "https:example.com/module2.js"; +import "https://///example.com\\module2.js"; +import "https://example.com/foo/../module2.js";+ +
So in this second example, only one fetch and one module evaluation will occur.
+ +Note that this behavior is the same as how shared workers are keyed by their parsed constructor url.
+To resolve a module specifier given a module script script and a string specifier, perform the following steps. It will return either an