/
index.html
92 lines (78 loc) · 2.53 KB
/
index.html
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
<p>worker template error match:</p>
<code>
const worker = new Worker(new URL('./worker.js', import.meta.url))
</code>
<h2 class="format-iife">format iife:</h2>
<div>Expected values: <span class="mode-true"></span></div>
<button class="ping">Ping</button>
<div>
Response from worker: <span class="pong"></span><span class="mode"></span>
</div>
<div>bundle-with-plugin: <span class="bundle-with-plugin"></span></div>
<button class="ping-inline">Ping Inline Worker</button>
<div>Response from inline worker: <span class="pong-inline"></span></div>
<button class="ping-ts-output">Ping Possible Compiled TS Worker</button>
<div>
Response from worker imported from code that might be compiled TS:
<span class="pong-ts-output"></span>
</div>
<button class="tick-shared">Tick Shared Worker</button>
<div>
Tick from shared worker, it syncs between pages:
<span class="tick-count">0</span>
</div>
<p>
new Worker(new URL('./url-worker.js', import.meta.url), { type: 'module' })
<span class="classname">.worker-import-meta-url</span>
</p>
<code class="worker-import-meta-url"></code>
<p>
new SharedWorker(new URL('./url-shared-worker.js', import.meta.url), { type:
'module' })
<span class="classname">.shared-worker-import-meta-url</span>
</p>
<code class="shared-worker-import-meta-url"></code>
<p>
import NestedWorker from './worker-nested-worker?worker' - nested worker
<span class="classname">.nested-worker</span>
</p>
<code class="nested-worker"></code>
<p>
new Worker(new URL('./classic-worker.js', import.meta.url))
<span class="classname">.classic-worker</span>
</p>
<code class="classic-worker"></code>
<p>
new SharedWorker(new URL('./classic-shared-worker.js', import.meta.url), {
type: 'classic' })
<span class="classname">.classic-shared-worker</span>
</p>
<code class="classic-shared-worker"></code>
<hr />
<h2 class="format-es"></h2>
<p>
worker emit chunk <br />
module and worker:worker in worker file <br />
module and worker:module in worker file <br />
<span class="classname">.emti-chunk-worker</span>
</p>
<code class="emti-chunk-worker"></code>
<p>
worker dynamic import to emit chunk
<span class="classname">.emti-chunk-dynamic-import-worker</span>
</p>
<code class="emti-chunk-dynamic-import-worker"></code>
<p>
module and worker:worker in simple file
<span class="classname">.module-and-worker-worker</span>
</p>
<code class="module-and-worker-worker"></code>
<style>
p {
background: rgba(0, 0, 0, 0.1);
}
.classname {
color: green;
}
</style>
<script type="module" src="./worker/main.js"></script>