WICG / import-maps

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

Fix rejection of multiple import maps #242

Closed hiroshige-g closed 3 years ago

hiroshige-g commented 3 years ago

Previously, we intended to reject second and subsequent import maps by checking whether node document's pending import map script is non-null, but this didn't work because after import maps are registered pending import map script is cleared. This PR fixes this by clearing acquiring import maps on preparing the first import map, rejecting second and subsequent import maps on preparation with error events.

Alternative considered: It might be better to set Document's import map to an empty import map on second import map, because it would prevent developers more effectively from depending on the behavior of multiple import maps cases. However, this was more complicated to specify (e.g. the first import map should be canceled on preparing the second import map and is hard to receive error events).

WPT: https://github.com/web-platform-tests/wpt/pull/27117 Chromium CL: https://chromium-review.googlesource.com/c/chromium/src/+/2618838


Preview | Diff