Skip to content

Commit 083d3cc

Browse files
committed
conditional remove webwokers during compilation
1 parent 49207c2 commit 083d3cc

4 files changed

Lines changed: 199 additions & 3 deletions

File tree

package-lock.json

Lines changed: 179 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"chai": "^4.2.0",
4343
"eslint": "^8.0.1",
4444
"mocha": "^8.2.1",
45-
"rollup": "^2.38.5"
45+
"rollup": "^2.38.5",
46+
"rollup-plugin-jscc": "^2.0.0"
4647
}
4748
}

rollup.cjs.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs";
22
import { builtinModules as builtin } from "module";
3+
import jscc from 'rollup-plugin-jscc'
34

45
const pkg = JSON.parse(fs.readFileSync("./package.json"));
56

@@ -12,5 +13,10 @@ export default {
1213
external: [
1314
...Object.keys(pkg.dependencies),
1415
...builtin,
15-
]
16+
],
17+
plugins: [
18+
jscc({
19+
values: { _SES: process.env.SES },
20+
})
21+
],
1622
};

src/threadman.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ const MEM_SIZE = 25; // Memory size in 64K Pakes (1600Kb)
2424

2525
import thread from "./threadman_thread.js";
2626
import os from "os";
27+
28+
/*#if _SES
29+
//#else */
2730
import Worker from "web-worker";
31+
//#endif
2832

2933
class Deferred {
3034
constructor() {
@@ -81,7 +85,10 @@ export default async function buildThreadManager(wasm, singleThread) {
8185
// tm.pTmp1 = tm.alloc(curve.G2.F.n8*3);
8286

8387

88+
/*#if _SES
89+
//#else */
8490
if (singleThread) {
91+
//#endif
8592
tm.code = wasm.code;
8693
tm.taskManager = thread();
8794
await tm.taskManager([{
@@ -90,6 +97,8 @@ export default async function buildThreadManager(wasm, singleThread) {
9097
code: tm.code.slice()
9198
}]);
9299
tm.concurrency = 1;
100+
/*#if _SES
101+
//#else */
93102
} else {
94103
tm.workers = [];
95104
tm.pendingDeferreds = [];
@@ -133,6 +142,8 @@ export default async function buildThreadManager(wasm, singleThread) {
133142
await Promise.all(initPromises);
134143

135144
}
145+
//#endif
146+
136147
return tm;
137148

138149
function getOnMsg(i) {

0 commit comments

Comments
 (0)