Skip to content

Commit e6c35ef

Browse files
committed
Add rollup test for createWorker
1 parent 5b6982b commit e6c35ef

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

test/rollup/app-createWorker.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createWorker } from "../../createWorker.mjs"
2+
import { spawn, Thread } from "../../"
3+
4+
async function run() {
5+
const add = await spawn(await createWorker("./worker.js", {backend: "node"}))
6+
const result = await add(2, 3)
7+
await Thread.terminate(add)
8+
return result
9+
}
10+
11+
run().then(result => {
12+
console.log(`Result: ${result}`)
13+
puppet.exit(0)
14+
}).catch(error => {
15+
console.error(error)
16+
puppet.exit(1)
17+
})

test/rollup/rollup.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ test("can be bundled using rollup", async t => {
1212
...config
1313
})
1414

15+
const appCreateWorkerBundleP = rollup({
16+
input: path.resolve(__dirname, "app-createWorker.js"),
17+
...config
18+
})
19+
1520
const workerBundleP = rollup({
1621
input: path.resolve(__dirname, "worker.js"),
1722
...config
@@ -22,12 +27,17 @@ test("can be bundled using rollup", async t => {
2227
format: "iife"
2328
})
2429

30+
const appCreateWorkerBundleWriteP = (await appCreateWorkerBundleP).write({
31+
dir: path.resolve(__dirname, "dist"),
32+
format: "es"
33+
})
34+
2535
const workerBundleWriteP = (await workerBundleP).write({
2636
dir: path.resolve(__dirname, "dist"),
2737
format: "iife"
2838
})
2939

30-
await Promise.all([appBundleWriteP, workerBundleWriteP])
40+
await Promise.all([appBundleWriteP, workerBundleWriteP, appCreateWorkerBundleWriteP])
3141

3242
if (process.platform === "win32") {
3343
// Quick-fix for weird Windows issue in CI

0 commit comments

Comments
 (0)