* 仕様書

[REFS[
- [1] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-02-16 01:30:20 +09:00]] 版) <https://html.spec.whatwg.org/#resolve-a-module-specifier>
]REFS]

* 解決

[2] [DFN[[RUBYB[モジュール指定子の解決]@en[resolve a module specifier]]]]は、
[VAR[基底URL]]と[[JavaScript文字列]][VAR[指定子]]について、
次のようにします [SRC[>>1]]。

[FIG(steps)[
= [3] [VAR[結果]]を、[VAR[指定子]]に[[URL構文解析器]]を適用した結果に設定します。
= [4] [VAR[結果]]が失敗''以外''なら、
== [5] [VAR[結果]]を返します。
= [6] それ以外なら、
== [7] [VAR[指定子]]の先頭が [CODE[[[/]]]]、[CODE[[[./]]]]、[CODE[[[../]]]] のいずれかなら、
=== [10] [VAR[[[基底URL]]]]について[VAR[指定子]]に[[URL構文解析器]]を適用した結果を返します。
== [8] それ以外なら、
=== [9] 失敗を返します。
]FIG]

[11] つまり[[絶対URL]]や[[絶対パス]]や [CODE[[[./]]]] や [CODE[[[../]]]]
から始まる [[URL]] なら、普通の [[URL]] と解釈します。
しかし [CODE[hogehoge]] など他の[[相対URL]]は将来の拡張のために予約されています [SRC[>>1]]。

[12] この処理は、
[CODE[import][import()]]、
[[モジュールスクリプトの作成]]と、
[[モジュールスクリプト]]の[[fetch][スクリプトのfetch]]中に呼び出されます。

* 歴史

[13] [CITE@en[Don't handle impossible errors in HostResolveImportedModule]]
([[domenic]]著, [TIME[2017-05-13 01:59:57 +09:00]])
<https://github.com/whatwg/html/commit/616df18cd9e6c17878db5167909c69ca9f9d2906>

[14] [CITE@en[Improve module instantiation/evaluation, especially around errors]]
([[domenic]]著, [TIME[2017-08-04 05:13:45 +09:00]])
<https://github.com/whatwg/html/commit/2b408b65a11fe76b6588b744e0ae74d30ff29b43>

[15] [CITE@en[Integrate dynamic import()]]
([[domenic]]著, [TIME[2017-09-14 21:11:01 +09:00]])
<https://github.com/whatwg/html/commit/d4d1704f9c0efbeed78b885d566af17545b8b5fe>

[16] [CITE@en[Editorial: “a module specifiers” → “module specifiers”]]
([[mathiasbynens]]著, [TIME[2017-11-04 16:06:06 +09:00]])
<https://github.com/whatwg/html/commit/2757de33552e6d9d0169e5a99c268db49e18b972>

[17] [CITE@en[Editorial: Fix typo by mathiasbynens · Pull Request #3192 · whatwg/html]]
([TIME[2017-11-06 12:40:56 +09:00]])
<https://github.com/whatwg/html/pull/3192>

[18] [CITE@en[Initialize script's base URL earlier]]
([[TimothyGu]]著, [TIME[2018-01-16 09:38:44 +09:00]])
<https://github.com/whatwg/html/commit/34ca9e5dcaaba10b22553d3235aaf7eca919d7ab>

[19] [CITE@en[Initialize script's base URL earlier by TimothyGu · Pull Request #3352 · whatwg/html]]
([TIME[2018-01-18 15:55:07 +09:00]])
<https://github.com/whatwg/html/pull/3352>

[20] [CITE@en[Editorial: change "resolve a module specifier" to take a URL]]
([[domfarolino]]著, [TIME[2018-07-10 05:10:41 +09:00]])
<https://github.com/whatwg/html/commit/8176d055eaef62cad03327a7cc47c5c7926ffb0c>

[21] [CITE@en[Resolve a module specifier now takes a base URL by domfarolino · Pull Request #3807 · whatwg/html]]
([TIME[2018-07-26 21:38:53 +09:00]])
<https://github.com/whatwg/html/pull/3807>