-
Notifications
You must be signed in to change notification settings - Fork 4
/
14.txt
286 lines (208 loc) · 12.3 KB
/
14.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
[53] [[JavaScript]] の[DFN[モジュールスクリプト]]は、
[[スクリプト]]の[[コンポーネント]]の単位の一つです。
* 仕様書
[REFS[
- [21] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-01-21 11:56:00 +09:00]] 版) <https://html.spec.whatwg.org/#concept-module-script-module-record>
- [29] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-02-14 16:33:19 +09:00]] 版) <https://html.spec.whatwg.org/#concept-workerglobalscope-type>
- [31] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-02-14 16:33:19 +09:00]] 版) <https://html.spec.whatwg.org/#workertype>
]REFS]
* 呼称
[32] [[JavaScript]] は[[モジュール]]、 [[HTML]] は[[モジュールスクリプト]]と呼んでいます。
;; [[スクリプト]]参照。
[40] [[HTML]] は明確化のために[[仕様書]]の用語としてそう呼んでいるだけで、
[[API]] では [CODE[module]] という語で表しています。
* 文脈
[41] [CODE(HTMLe)@en[script]] [[要素]]により指定できます。
[EG[
[45]
[PRE(HTML code)[
<script type=module src=path/to/module.js></script>
]PRE]
]EG]
[42] [[ワーカー]]の作成時にも指定できます。
[EG[
[46]
[PRE(JS code)[
var worker = [[new Worker]] ("path/to/module.js", {type: "module"});
]PRE]
]EG]
[44] [[要素]]や[[ワーカー]]からの指定では、[[ワーカースクリプト]]の [[URL]]
を使って指定します。従来の[[古典スクリプト]]と区別するため、
[CODE(HTMLa)@en[type][<script type>]] を [CODE[module][モジュールスクリプト]]
と明記する必要があります。
[43] [[JavaScript]] 内からも指定できます。[[モジュール指定子]]を使います。
* 状態
[20] [[モジュールスクリプト]]の持つ状態については、
[[スクリプト]]を参照。
[22] [[モジュールスクリプト]]の[DFN[[F[[RUBYB[[[モジュール記録]]]@en[module record]]]]]]は、
構文解析され、[[評価]]できる状態の[[モジュール]]を表す [[Source Text Module Record]]
(またはエラー時の [CODE[null]]) [SRC[>>21]] です。
[30] [CODE(DOMi)@en[[[WorkerGlobalScope]]]] の[F[型][スクリプトの型]]の値
[DFN[[CODE[[[module]]]]]] [SRC[>>29]] や [CODE[[[WorkerType]]]] の値
[DFN[[CODE[[[module]]]]]] [SRC[>>31]] は、[[モジュールスクリプト]]を表します。
* 作成
[26] [[モジュールスクリプトの作成]]を参照。
* 実行
[27] [[モジュールスクリプトの実行]]を参照。
* 古典スクリプトとの違い
[33] [[スクリプト]]を参照。
* 歴史
[1]
[CITE[The <module> Tag]] <http://json.org/module.html>
([[名無しさん]] [WEAK[2006-10-31 01:57:36 +00:00]])
[2] [CITE@en[Bug 25715 – ''''''[''''''imports'''''']'''''': Unify loading and dependency resolution model with ES6 modules]]
( ([TIME[2014-05-24 03:38:23 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=25715>
[3] [CITE@en[Bug 25868 – <script module>]]
( ([TIME[2014-05-24 03:40:10 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=25868>
[4] [CITE[dherman/web-modules]]
( ([TIME[2014-05-24 03:40:42 +09:00]] 版))
<https://github.com/dherman/web-modules>
[5] [CITE[IRC logs: freenode / #whatwg / 20140522]]
( ([TIME[2014-05-25 15:51:32 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140522>
[6] [CITE[Integrating the Webs' dependency systems]]
( ([TIME[2014-05-26 02:52:02 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-May/037265.html>
[7] [CITE[IRC logs: freenode / #whatwg / 20140612]]
( ([TIME[2014-06-13 18:14:57 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140612>
[8] [CITE[Adding out-of-band dependencies for a module]]
( ([TIME[2014-08-16 00:25:20 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038743.html>
[9] [CITE[Modules and dependencies known before the load]]
( ([TIME[2014-08-16 00:25:20 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038802.html>
[10] [CITE[Dependencies for non-ES modules]]
( ([TIME[2014-08-16 00:25:20 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038806.html>
[11] [CITE[Normalize hook default Web behaviour]]
( ([TIME[2014-08-16 00:25:20 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038821.html>
[12] [CITE[Importing modules inside HTML imports]]
( ([TIME[2014-08-16 00:47:03 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038824.html>
[13] [CITE[Changing dependencies]]
( ([TIME[2014-08-16 17:22:42 +09:00]] 版))
<https://mail.mozilla.org/pipermail/es-discuss/2014-August/038826.html>
[14] [CITE@en[''''''[''''''whatwg'''''']'''''' Preloading and deferred loading of scripts and other resources]]
( ([[Ian Hickson]] 著, [TIME[2014-08-23 09:44:23 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Aug/0177.html>
[15] [CITE[dherman/web-modules]]
( ([TIME[2014-03-20 08:09:50 +09:00]] 版))
<https://github.com/dherman/web-modules/>
[16] [CITE[IRC logs: freenode / #whatwg / 20140328]]
( ([TIME[2014-03-30 01:03:25 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140328>
[17] [CITE@en[25868 – <script module>]]
([TIME[2015-12-29 15:22:30 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=25868>
[18] [CITE@en[Add <script type="module"> and module resolution/fetching/evaluation by domenic · Pull Request #443 · whatwg/html]]
([TIME[2015-12-29 15:22:36 +09:00]] 版)
<https://github.com/whatwg/html/pull/443>
[117] [CITE@en[Add <script type="module"> and module resolution/fetching/evaluation · whatwg/html@cd1a9fb]]
([TIME[2016-01-21 22:53:08 +09:00]] 版)
<https://github.com/whatwg/html/commit/cd1a9fb1e83f7d0bc30be8b34ecdaf444a0b19a4>
[19] [CITE@en[Merge pull request #360 from dglazkov/html-modules · w3c/webcomponents@07485f2]]
([TIME[2016-01-07 11:54:02 +09:00]] 版)
<https://github.com/w3c/webcomponents/commit/07485f25730284e1a4e1ece9b93a23d0e91a1d1b>
[23] [CITE@ja[ECMA-262 6th (ES 2015) のモジュールについて (入門編) - ひだまりソケットは壊れない]]
([TIME[2016-01-30 11:19:14 +09:00]] 版)
<http://vividcode.hatenablog.com/entry/ecmascript/module-introduction>
[24] [CITE@en[webcomponents/HTML-Imports-and-ES-Modules.md at html-modules · dglazkov/webcomponents]]
([TIME[2016-02-01 20:54:47 +09:00]] 版)
<https://github.com/dglazkov/webcomponents/blob/html-modules/proposals/HTML-Imports-and-ES-Modules.md>
[25] [CITE@en[Use "credentials mode" instead of "CORS setting" for modules · whatwg/html@7a0ce07]]
([TIME[2016-02-04 17:39:11 +09:00]] 版)
<https://github.com/whatwg/html/commit/7a0ce073a8fbade8f44d0e2d4c709ad7cf3ee312>
[28] [CITE@en[Add module workers · whatwg/html@e3a5bb7]]
([TIME[2016-02-15 22:48:28 +09:00]] 版)
<https://github.com/whatwg/html/commit/e3a5bb757f64374c37d8c4528c01298463ef0b2a>
[34] [CITE@en[Support module service workers, and update for ES6 · Issue #831 · slightlyoff/ServiceWorker]]
([TIME[2016-03-01 11:32:12 +09:00]] 版)
<https://github.com/slightlyoff/ServiceWorker/issues/831>
[35] [CITE@en[Pass parser metadata to Fetch · whatwg/html@e6500b9]]
([TIME[2016-04-16 22:39:22 +09:00]] 版)
<https://github.com/whatwg/html/commit/e6500b90244376c023e7b78642dbc7b86829233f>
[36] [CITE[The WHATWG Blog — Adding JavaScript modules to the web platform]]
([TIME[2016-04-17 13:31:54 +09:00]] 版)
<https://blog.whatwg.org/js-modules>
[37] [CITE@en-US[Previewing ES6 Modules and more from ES2015, ES2016 and beyond | Microsoft Edge Dev Blog]]
( ([TIME[2016-05-19 10:16:47 +09:00]]))
<https://blogs.windows.com/msedgedev/2016/05/17/es6-modules-and-beyond/>
[38] [CITE@en[Add `application/javascript+module` mime to remove ambiguity · Issue #322 · tc39/ecma262]]
([TIME[2016-06-27 13:52:19 +09:00]])
<https://github.com/tc39/ecma262/issues/322>
[39] [CITE@en[Handle error cases during module script tree fetching/running better]]
([[domenic]]著, [TIME[2016-08-09 12:06:32 +09:00]])
<https://github.com/whatwg/html/commit/e1af86747f591e33fd0f3f21f301dc866868c9d4>
[47] [CITE@en[Import module function (assuming <script type="module"> is implemented)]]
([TIME[2017-01-04 22:44:59 +09:00]])
<https://gist.github.com/domenic/fd84ee5f4e2dc0278ab1>
[48] [CITE@en[design/JS.md at master · WebAssembly/design]]
([TIME[2017-01-18 15:46:49 +09:00]])
<https://github.com/WebAssembly/design/blob/master/JS.md>
[49] [CITE@en[design/Modules.md at master · WebAssembly/design]]
([TIME[2017-01-18 15:47:48 +09:00]])
<https://github.com/WebAssembly/design/blob/master/Modules.md>
[50] [CITE@en[Fix error cases of <script type=module>]]
([[domenic]]著, [TIME[2017-05-13 01:50:49 +09:00]])
<https://github.com/whatwg/html/commit/115763124a641e8814665c5014d28155f95ff441>
[51] [CITE@en[Simpler path for adoption of modules in workers · Issue #2888 · whatwg/html]]
([TIME[2017-08-06 21:37:01 +09:00]])
<https://github.com/whatwg/html/issues/2888>
[52] [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>
[54] [CITE@en[Circular module graphs instantiate too early · Issue #2629 · whatwg/html]]
([TIME[2017-09-03 16:22:41 +09:00]])
<https://github.com/whatwg/html/issues/2629>
[55] [CITE@en[Module script errors maybe shouldn't propagate to descendant scripts so much · Issue #2630 · whatwg/html]]
([TIME[2017-09-03 16:23:10 +09:00]])
<https://github.com/whatwg/html/issues/2630>
[56] [CITE@en[Rely on the JavaScript spec to handle more module errors by domenic · Pull Request #2674 · whatwg/html]]
([TIME[2017-09-03 16:23:38 +09:00]])
<https://github.com/whatwg/html/pull/2674>
[57] [CITE@en[Resolving modules via definition · Issue #3056 · whatwg/html]]
([TIME[2017-09-21 12:28:36 +09:00]])
<https://github.com/whatwg/html/issues/3056>
[58] [CITE@en[Fix module script error handling, again by domenic · Pull Request #2991 · whatwg/html]]
([TIME[2017-12-19 00:44:22 +09:00]])
<https://github.com/whatwg/html/pull/2991>
[59] [CITE@en[Do not remember module instantiation errors. by GeorgNeis · Pull Request #1006 · tc39/ecma262]]
([TIME[2017-12-19 00:51:31 +09:00]])
<https://github.com/tc39/ecma262/pull/1006>
[60] [CITE@en[Fix authoring guidance to allow async="" on inline module scripts]]
([[domenic]]著, [TIME[2018-01-06 03:37:30 +09:00]])
<https://github.com/whatwg/html/commit/271f19c34786db04a17c16c24807a33113894a68>
[61] [CITE@en[async="" should be allowed on inline module scripts · Issue #3319 · whatwg/html]]
([TIME[2018-02-26 00:11:14 +09:00]])
<https://github.com/whatwg/html/issues/3319>
[62] [CITE@en[Fix authoring guidance to allow async="" on inline module scripts by domenic · Pull Request #3324 · whatwg/html]]
([TIME[2018-02-26 00:11:33 +09:00]])
<https://github.com/whatwg/html/pull/3324>
[63] [CITE@en[Add <link> rel="modulepreload"]]
([[domenic]]著, [TIME[2017-12-15 05:04:40 +09:00]])
<https://github.com/whatwg/html/commit/7c28027b80208aa6b126fa7b086c44877f584178>
[64] [CITE@en[preload, destinations, and module scripts · Issue #486 · whatwg/fetch]]
([TIME[2018-03-20 15:15:50 +09:00]])
<https://github.com/whatwg/fetch/issues/486>
[65] [CITE@en[Add <link> rel="modulepreload" by domenic · Pull Request #2383 · whatwg/html]]
([TIME[2018-03-20 15:20:54 +09:00]])
<https://github.com/whatwg/html/pull/2383>
[66] [CITE@en[Script modules and credentials · Issue #2557 · whatwg/html]]
([TIME[2018-04-21 15:32:03 +09:00]])
<https://github.com/whatwg/html/issues/2557>
[67] [CITE@en[Editorial: use .mjs for modules more consistently in examples]]
([[mathiasbynens]]著, [TIME[2018-07-12 05:47:34 +09:00]])
<https://github.com/whatwg/html/commit/51ac91fd500bcfcb090bafa59ac4d63b92066fd6>
[68] [CITE@en[Use .mjs for modules more consistently by mathiasbynens · Pull Request #3810 · whatwg/html]]
([TIME[2018-07-13 16:08:05 +09:00]])
<https://github.com/whatwg/html/pull/3810>
[69] [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>
[70] [CITE@en[Resolve a module specifier now takes a base URL by domfarolino · Pull Request #3807 · whatwg/html]]
([TIME[2018-07-26 21:39:23 +09:00]])
<https://github.com/whatwg/html/pull/3807>