What is the issue with the HTML Standard?
https://html.spec.whatwg.org/#merge-existing-and-new-import-maps
6. For each record of global's resolved module set:
1. For each specifier → url of newImportMapImports:
1. If specifier starts with record's specifier, then:
....
2. Remove newImportMapImports[specifier].
I think in Step 6.1.1, the two strings are reversed; the correct one should be
6.1.1. If specifier is a code unit prefix of record's specifier
or
6.1.1. If record's specifier starts with specifier
Take WPT /import-maps/not-overridden/prefix.html as an example
first it imports "resources/log.js?pipe=sub&name=A"
Then adds an import map with imports, with an entry of 'resources' : '/foobar'
Finally, it uses import.meta.resolve("/resources/log.js?pipe=sub&name=A") to get the resolved URI
According to the spec,
when the import map is merged,
the specifier "../resources/" doesn't start with the resolved module set's specifier "resources/log.js?pipe=sub&name=A", so the entry will be added into the import map, which will map the "/resources/" to "/foobar" in the following import.meta.resolve call, and make the test fail unexpectedly.
Now with the updated spec, the resolved module set's specifier starts with the specifier in the new import map's imports, so the entry in the new import map will be removed, and the test will pass correctly.
The other WPTs
"/import-maps/multiple-import-maps/already-resolved-dropped.html"
"/import-maps/not-overridden/dynamic.html" are also be used to indicate that the order is wrong.
CC @yoavweiss and reviewers @domenic @guybedford