モジュール

モジュールスクリプト (JavaScript)

[53] JavaScriptモジュールスクリプトは、 スクリプトコンポーネントの単位の一つです。

仕様書

呼称

[32] JavaScriptモジュールHTMLモジュールスクリプトと呼んでいます。

[40] HTML は明確化のために仕様書の用語としてそう呼んでいるだけで、 API では module という語で表しています。

文脈

[41] script 要素により指定できます。

[45]

<script type=module src=path/to/module.js></script>

[42] ワーカーの作成時にも指定できます。

[46]

var worker = new Worker ("path/to/module.js", {type: "module"});

[44] 要素ワーカーからの指定では、ワーカースクリプトURL を使って指定します。従来の古典スクリプトと区別するため、 typemodule と明記する必要があります。

[43] JavaScript 内からも指定できます。モジュール指定子を使います。

状態

[20] モジュールスクリプトの持つ状態については、 スクリプトを参照。

[22] モジュールスクリプトモジュール記録 (module record) は、 構文解析され、評価できる状態のモジュールを表す Source Text Module Record (またはエラー時の null) >>21 です。

[30] WorkerGlobalScopeの値 module >>29WorkerType の値 module >>31 は、モジュールスクリプトを表します。

作成

[26] モジュールスクリプトの作成を参照。

実行

[27] モジュールスクリプトの実行を参照。

古典スクリプトとの違い

[33] スクリプトを参照。

歴史

[1] The <module> Tag <http://json.org/module.html> (名無しさん 2006-10-31 01:57:36 +00:00)

[2] Bug 25715 – [imports]: Unify loading and dependency resolution model with ES6 modules ( ( 版)) <https://www.w3.org/Bugs/Public/show_bug.cgi?id=25715>

[3] Bug 25868 – <script module> ( ( 版)) <https://www.w3.org/Bugs/Public/show_bug.cgi?id=25868>

[4] dherman/web-modules ( ( 版)) <https://github.com/dherman/web-modules>

[5] IRC logs: freenode / #whatwg / 20140522 ( ( 版)) <http://krijnhoetmer.nl/irc-logs/whatwg/20140522>

[6] Integrating the Webs' dependency systems ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-May/037265.html>

[7] IRC logs: freenode / #whatwg / 20140612 ( ( 版)) <http://krijnhoetmer.nl/irc-logs/whatwg/20140612>

[8] Adding out-of-band dependencies for a module ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038743.html>

[9] Modules and dependencies known before the load ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038802.html>

[10] Dependencies for non-ES modules ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038806.html>

[11] Normalize hook default Web behaviour ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038821.html>

[12] Importing modules inside HTML imports ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038824.html>

[13] Changing dependencies ( ( 版)) <https://mail.mozilla.org/pipermail/es-discuss/2014-August/038826.html>

[14] [whatwg] Preloading and deferred loading of scripts and other resources ( (Ian Hickson 著, 版)) <http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Aug/0177.html>

[15] dherman/web-modules ( ( 版)) <https://github.com/dherman/web-modules/>

[16] IRC logs: freenode / #whatwg / 20140328 ( ( 版)) <http://krijnhoetmer.nl/irc-logs/whatwg/20140328>

[17] 25868 – <script module> ( 版) <https://www.w3.org/Bugs/Public/show_bug.cgi?id=25868>

[18] Add <script type="module"> and module resolution/fetching/evaluation by domenic · Pull Request #443 · whatwg/html ( 版) <https://github.com/whatwg/html/pull/443>

[117] Add <script type="module"> and module resolution/fetching/evaluation · whatwg/html@cd1a9fb ( 版) <https://github.com/whatwg/html/commit/cd1a9fb1e83f7d0bc30be8b34ecdaf444a0b19a4>

[19] Merge pull request #360 from dglazkov/html-modules · w3c/webcomponents@07485f2 ( 版) <https://github.com/w3c/webcomponents/commit/07485f25730284e1a4e1ece9b93a23d0e91a1d1b>

[23] ECMA-262 6th (ES 2015) のモジュールについて (入門編) - ひだまりソケットは壊れない ( 版) <http://vividcode.hatenablog.com/entry/ecmascript/module-introduction>

[24] webcomponents/HTML-Imports-and-ES-Modules.md at html-modules · dglazkov/webcomponents ( 版) <https://github.com/dglazkov/webcomponents/blob/html-modules/proposals/HTML-Imports-and-ES-Modules.md>

[25] Use "credentials mode" instead of "CORS setting" for modules · whatwg/html@7a0ce07 ( 版) <https://github.com/whatwg/html/commit/7a0ce073a8fbade8f44d0e2d4c709ad7cf3ee312>

[28] Add module workers · whatwg/html@e3a5bb7 ( 版) <https://github.com/whatwg/html/commit/e3a5bb757f64374c37d8c4528c01298463ef0b2a>

[34] Support module service workers, and update for ES6 · Issue #831 · slightlyoff/ServiceWorker ( 版) <https://github.com/slightlyoff/ServiceWorker/issues/831>

[35] Pass parser metadata to Fetch · whatwg/html@e6500b9 ( 版) <https://github.com/whatwg/html/commit/e6500b90244376c023e7b78642dbc7b86829233f>

[36] The WHATWG Blog — Adding JavaScript modules to the web platform ( 版) <https://blog.whatwg.org/js-modules>

[37] Previewing ES6 Modules and more from ES2015, ES2016 and beyond | Microsoft Edge Dev Blog ( ()) <https://blogs.windows.com/msedgedev/2016/05/17/es6-modules-and-beyond/>

[38] Add `application/javascript+module` mime to remove ambiguity · Issue #322 · tc39/ecma262 () <https://github.com/tc39/ecma262/issues/322>

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

[47] Import module function (assuming <script type="module"> is implemented) () <https://gist.github.com/domenic/fd84ee5f4e2dc0278ab1>

[48] design/JS.md at master · WebAssembly/design () <https://github.com/WebAssembly/design/blob/master/JS.md>

[49] design/Modules.md at master · WebAssembly/design () <https://github.com/WebAssembly/design/blob/master/Modules.md>

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

[51] Simpler path for adoption of modules in workers · Issue #2888 · whatwg/html () <https://github.com/whatwg/html/issues/2888>

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

[54] Circular module graphs instantiate too early · Issue #2629 · whatwg/html () <https://github.com/whatwg/html/issues/2629>

[55] Module script errors maybe shouldn't propagate to descendant scripts so much · Issue #2630 · whatwg/html () <https://github.com/whatwg/html/issues/2630>

[56] Rely on the JavaScript spec to handle more module errors by domenic · Pull Request #2674 · whatwg/html () <https://github.com/whatwg/html/pull/2674>

[57] Resolving modules via definition · Issue #3056 · whatwg/html () <https://github.com/whatwg/html/issues/3056>

[58] Fix module script error handling, again by domenic · Pull Request #2991 · whatwg/html () <https://github.com/whatwg/html/pull/2991>

[59] Do not remember module instantiation errors. by GeorgNeis · Pull Request #1006 · tc39/ecma262 () <https://github.com/tc39/ecma262/pull/1006>

[60] Fix authoring guidance to allow async="" on inline module scripts (domenic著, ) <https://github.com/whatwg/html/commit/271f19c34786db04a17c16c24807a33113894a68>

[61] async="" should be allowed on inline module scripts · Issue #3319 · whatwg/html () <https://github.com/whatwg/html/issues/3319>

[62] Fix authoring guidance to allow async="" on inline module scripts by domenic · Pull Request #3324 · whatwg/html () <https://github.com/whatwg/html/pull/3324>

[63] Add <link> rel="modulepreload" (domenic著, ) <https://github.com/whatwg/html/commit/7c28027b80208aa6b126fa7b086c44877f584178>

[64] preload, destinations, and module scripts · Issue #486 · whatwg/fetch () <https://github.com/whatwg/fetch/issues/486>

[65] Add <link> rel="modulepreload" by domenic · Pull Request #2383 · whatwg/html () <https://github.com/whatwg/html/pull/2383>

[66] Script modules and credentials · Issue #2557 · whatwg/html () <https://github.com/whatwg/html/issues/2557>

[67] Editorial: use .mjs for modules more consistently in examples (mathiasbynens著, ) <https://github.com/whatwg/html/commit/51ac91fd500bcfcb090bafa59ac4d63b92066fd6>

[68] Use .mjs for modules more consistently by mathiasbynens · Pull Request #3810 · whatwg/html () <https://github.com/whatwg/html/pull/3810>

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

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