summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/compile/workers/worker.ts
diff options
context:
space:
mode:
authorAndreu Botella <andreu@andreubotella.com>2023-03-19 23:32:54 +0100
committerGitHub <noreply@github.com>2023-03-19 23:32:54 +0100
commit090169cfbc6699486765b729d532b5b837210b12 (patch)
tree6872c34b8d9c6ac9b3ef05c2efb7a54b7c96bb28 /cli/tests/testdata/compile/workers/worker.ts
parentbf149d047f4f768ced17d76c47623ca13c90f7e7 (diff)
feat(compile): Add support for web workers in standalone mode (#17657)
This commit adds support for spawning Web Workers in self-contained binaries created with "deno compile" subcommand. As long as module requested in "new Worker" constructor is part of the eszip (by means of statically importing it beforehand, or using "--include" flag), then the worker can be spawned.
Diffstat (limited to 'cli/tests/testdata/compile/workers/worker.ts')
-rw-r--r--cli/tests/testdata/compile/workers/worker.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/tests/testdata/compile/workers/worker.ts b/cli/tests/testdata/compile/workers/worker.ts
new file mode 100644
index 000000000..a1c357ab1
--- /dev/null
+++ b/cli/tests/testdata/compile/workers/worker.ts
@@ -0,0 +1,14 @@
+/// <reference no-default-lib="true" />
+/// <reference lib="deno.worker" />
+
+if (import.meta.main) {
+ console.log("Hello from worker!");
+
+ addEventListener("message", (evt) => {
+ console.log(`Received ${evt.data}`);
+ console.log("Closing");
+ self.close();
+ });
+} else {
+ console.log("worker.js imported from main thread");
+}