HostResolveImportedModule()

import (JavaScript)

仕様書

Web ブラウザーの処理

[2] Webブラウザーは、 referencing指定子に関する HostResolveImportedModule を、次のようにしなければなりません >>1

  1. [3] 参照元スクリプトを、 referencingHostDefined に設定します。
  2. [5] URL を、参照元スクリプト指定子についてモジュール指定子を解決した結果に設定します。
  3. [4] 参照元スクリプト設定群オブジェクトモジュール写像 [ URL ] のモジュール記録を返します。

[13] つまり、与えられたモジュール指定子を解決して得られた URL が、既に読み込み済みのモジュールスクリプトURL であれば、 そのモジュールスクリプトが使われます。

[10] 静的import で使われます。

[8] Webブラウザーは、 referencing指定子promiseCapability に関する HostImportModuleDynamically を、次のようにしなければなりません>>1

  1. [9] スクリプトを、 referencingHostDefined に設定します。
  2. [12] URL を、スクリプト指定子についてモジュール指定子を解決した結果に設定します。
  3. [15] URL失敗の場合、
    1. [16] 完了を、新しい Completion に設定します。
      Type
      throw
      Value
      新しい TypeError
      Target
    2. [20] referencing指定子promiseCapability, 完了について FinishDynamicImport を実行します。
  4. [22] それ以外の場合、
    1. [23] オプション群を、 スクリプトfetchオプション群子孫スクリプトfetchオプション群に設定します。
    2. [21] モジュールスクリプトグラフのfetch を実行します。
      URL
      URL
      設定群オブジェクト
      referencing設定群オブジェクト
      終点
      script
      オプション群
      オプション群
      続きの処理
      >>11
  5. [33] 未定義を返します。

[11] 続きは、結果について、次のようにします。 >>1

  1. [24] 結果null の場合、
    1. [25] 完了を、新しい Completion に設定します。
      Type
      throw
      Value
      TypeError
      Target
    2. [26] referencing指定子promiseCapability完了について、 FinishDynamicImport を実行します。
  2. [27] それ以外の場合、
    1. [28] モジュールスクリプトの実行をします。
      スクリプト
      結果
      エラーを再び投げる
      例外を、投げられた例外に設定します。
    2. [29] 例外がある場合、
      1. [30] referencing指定子promiseCapability例外について FinishDynamicImport を実行します。
    3. [31] それ以外の場合、
      1. [32] referencing指定子promiseCapabilityNormalCompletion (未定義) について FinishDynamicImport を実行します。

歴史

[14] Handle error cases during module script tree fetching/running better (domenic著, ) https://github.com/whatwg/html/commit/e1af86747f591e33fd0f3f21f301dc866868c9d4

[17] Fix bad assert in HostResolveImportedModule (domenic著, ) https://github.com/whatwg/html/commit/e7041402890076aaf7095a3f8931ba0a00393b72

[18] Fix error cases of <script type=module> (domenic著, ) https://github.com/whatwg/html/commit/115763124a641e8814665c5014d28155f95ff441

[19] Don't handle impossible errors in HostResolveImportedModule (domenic著, ) https://github.com/whatwg/html/commit/616df18cd9e6c17878db5167909c69ca9f9d2906

[7] Improve module instantiation/evaluation, especially around errors (domenic著, ) https://github.com/whatwg/html/commit/2b408b65a11fe76b6588b744e0ae74d30ff29b43

[6] Integrate dynamic import() (domenic著, ) https://github.com/whatwg/html/commit/d4d1704f9c0efbeed78b885d566af17545b8b5fe

[35] Spec import() HTML integration · Issue #2315 · whatwg/html () https://github.com/whatwg/html/issues/2315

[36] Add integrity="" for module scripts, and integrate dynamic import() by domenic · Pull Request #3044 · whatwg/html () https://github.com/whatwg/html/pull/3044

[37] Specify which settings object is used for dynamic import (nhiroki著, ) https://github.com/whatwg/html/commit/07ab5082c326a0548b5d7665ac1524f1fa9e2818

[38] Specify which settings object is used for dynamic import by nhiroki · Pull Request #3700 · whatwg/html () https://github.com/whatwg/html/pull/3700

[39] Peeling out import() · Issue #149 · whatwg/loader () https://github.com/whatwg/loader/issues/149

[40] tc39/proposal-dynamic-import: import() proposal for JavaScript () https://github.com/tc39/proposal-dynamic-import

This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript. It is currently in stage 3 of the TC39 process. Previously it was discussed with the module-loading community in whatwg/loader#149.

[41] import() () https://tc39.github.io/proposal-dynamic-import/

[42] proposal-dynamic-import/HTML Integration.md at master · tc39/proposal-dynamic-import () https://github.com/tc39/proposal-dynamic-import/blob/master/HTML%20Integration.md

[43] Discussion: Towards a module map proposal · Issue #2547 · whatwg/html () https://github.com/whatwg/html/issues/2547

[44] Editorial: refactor classic and module scripts to be more alike (domenic著, ) https://github.com/whatwg/html/commit/dce999aac4d9deeefa3b338dd2aeb30c17669bc8

[45] Editorial: move base URL from "module script" to "script" (domenic著, ) https://github.com/whatwg/html/commit/5458513792ab00d58e6c91ba48faaa611d034a2e

[46] Add integrity="" for module scripts, and integrate dynamic import() by domenic · Pull Request #3044 · whatwg/html () https://github.com/whatwg/html/pull/3044

[47] Make integrity="" work on module scripts (domenic著, ) https://github.com/whatwg/html/commit/9275d955dcd604e959cfcc672e0c234b1b8c00db

[48] Integrate dynamic import() (domenic著, ) https://github.com/whatwg/html/commit/d4d1704f9c0efbeed78b885d566af17545b8b5fe

[49] Adds "audioworklet" and "paintworklet" as destinations. by bfgeek · Pull Request #527 · whatwg/fetch () https://github.com/whatwg/fetch/pull/527

[50] Dynamic import()  |  Web  |  Google Developers () https://developers.google.com/web/updates/2017/11/dynamic-import

[51] Peeling out import() · Issue #149 · whatwg/loader () https://github.com/whatwg/loader/issues/149

[52] New in Chrome 63  |  Web  |  Google Developers () https://developers.google.com/web/updates/2017/12/nic63?utm_source=feed&utm_medium=feed&utm_campaign

[53] Fix import() inside setTimeout()/setInterval() strings (domenic著, ) https://github.com/whatwg/html/commit/12cdfefad607fc824e6ea64a4b967fc24043f684

[54] setTimeout() base URL/script fetch options behavior seems wrong · Issue #3116 · whatwg/html () https://github.com/whatwg/html/issues/3116

[55] Fix import() inside setTimeout()/setInterval() strings by domenic · Pull Request #3117 · whatwg/html () https://github.com/whatwg/html/pull/3117

[56] DOM handler and import · Issue #32 · tc39/proposal-dynamic-import () https://github.com/tc39/proposal-dynamic-import/issues/32

[57] 今まで JavaScript APIURL は原則的に文書基底URL を使っていたので、その原則が崩れてしまうのは微妙。 でも外部スクリプトファイルの import が自身の URL じゃなくて使っている文書基底URLを使うようになると、 この上なく使いにくくなりそうだ。じゃあ import() もそれと一貫してほしいってことになるのは自然。

[58] eval "import()" setTimeout ("import()", ...) は含まれているスクリプトファイルの基底URLを引き継ぐ。 element.onclick = function () { import () } もそう。一方 element.setAttribute ("onclick", "import()") は文書の基底URLになる、のかな。 でもWebブラウザー発火させるより前に element.onclick にアクセスしたら、その時点でコンパイルされるけど、 どうなるのか。

[59] Editorial: change "resolve a module specifier" to take a URL (domfarolino著, ) https://github.com/whatwg/html/commit/8176d055eaef62cad03327a7cc47c5c7926ffb0c

[60] Resolve a module specifier now takes a base URL by domfarolino · Pull Request #3807 · whatwg/html () https://github.com/whatwg/html/pull/3807

[34] Do not run FinishDynamicImport steps in parallel (domenic著, ) https://github.com/whatwg/html/commit/4ee44da9eb0f94bfa77001e8bcf16ede6050630e

[61] Do not run FinishDynamicImport steps in parallel by domenic · Pull Request #4182 · whatwg/html () https://github.com/whatwg/html/pull/4182

[62] Dev edition: improve the "Scripting" subsection (domenic著, ) https://github.com/whatwg/html/commit/ebdd2a03de44c6a51e837dbb2dbe6400d8bc6b40

[63] Dev edition: improve the "Scripting" subsection by domenic · Pull Request #4183 · whatwg/html () https://github.com/whatwg/html/pull/4183

[64] Always set [[ScriptOrModule]] to null for event handler functions (domenic著, ) https://github.com/whatwg/html/commit/1d6eb9933701ea65f7a9dd670d37a2faa17b8f12

[65] import() behaviour in event handlers is path dependent · Issue #4267 · whatwg/html () https://github.com/whatwg/html/issues/4267

[66] Handle module resolution when there is no active script by domenic · Pull Request #4181 · whatwg/html () https://github.com/whatwg/html/pull/4181

[67] Always set [[ScriptOrModule]] to null for event handler functions by domenic · Pull Request #4302 · whatwg/html () https://github.com/whatwg/html/pull/4302

[68] Editorial: update some JavaScript spec references (domenic著, ) https://github.com/whatwg/html/commit/6227b7e91913d21157a1265f6e294a7a89f916c4