-
Notifications
You must be signed in to change notification settings - Fork 56
/
rollup.browser.esm.config.js
41 lines (40 loc) · 1.51 KB
/
rollup.browser.esm.config.js
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
import commonJS from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import thread from "./src/threadman_thread.js";
export default [
{
input: "main.js",
output: [
{
format: "es",
file: "build/browser.esm.js",
},
],
plugins: [
replace({
preventAssignment: true,
changed: "replaced",
delimiters: ["", ""],
/*
* The following variable replaces to true in the build in the similar way as snarkjs does.
* https://github.com/iden3/snarkjs/blob/ef9042451f98f254b520b8ce9b9544a849e90a5d/config/rollup.iife.config.js
*/
"process.browser": true,
"import Worker from \"web-worker\"": "",
/*
Because of some frontend frameworks uses monkey patching to track UI changes or other purposes (including Angular, AngularJS, Ember.js, JQuery...), it's important to make sure that the thread function is not modified by the framework and passing in the web worker as it is.
*/
"thread.toString()": JSON.stringify(thread.toString()),
}),
commonJS(),
nodeResolve({
browser: true,
}),
],
treeshake: {
// remove unused imports from the build
preset: "smallest",
},
},
];