1 | import typescript from "@rollup/plugin-typescript";
|
2 | import terser from "@rollup/plugin-terser";
|
3 | import { sync } from "rimraf";
|
4 |
|
5 | function config({ format, minify, input, ext = "js" }) {
|
6 | const dir = `dist/${format}/`;
|
7 | const minifierSuffix = minify ? ".min" : "";
|
8 | return {
|
9 | input: `./src/${input}.ts`,
|
10 | output: {
|
11 | name: "Comlink",
|
12 | file: `${dir}/${input}${minifierSuffix}.${ext}`,
|
13 | format,
|
14 | sourcemap: true,
|
15 | },
|
16 | plugins: [
|
17 | typescript({
|
18 | tsconfig: "./tsconfig.json",
|
19 | compilerOptions: {
|
20 | declaration: true,
|
21 | declarationDir: ".",
|
22 | sourceMap: true,
|
23 | outDir: "dist",
|
24 | },
|
25 | }),
|
26 | minify
|
27 | ? terser({
|
28 | compress: true,
|
29 | mangle: true,
|
30 | })
|
31 | : undefined,
|
32 | ].filter(Boolean),
|
33 | };
|
34 | }
|
35 |
|
36 | sync("dist");
|
37 |
|
38 | export default [
|
39 | { input: "comlink", format: "esm", minify: false, ext: "mjs" },
|
40 | { input: "comlink", format: "esm", minify: true, ext: "mjs" },
|
41 | { input: "comlink", format: "esm", minify: false },
|
42 | { input: "comlink", format: "esm", minify: true },
|
43 | { input: "comlink", format: "umd", minify: false },
|
44 | { input: "comlink", format: "umd", minify: true },
|
45 | { input: "node-adapter", format: "esm", minify: false, ext: "mjs" },
|
46 | { input: "node-adapter", format: "esm", minify: true, ext: "mjs" },
|
47 | { input: "node-adapter", format: "umd", minify: false },
|
48 | { input: "node-adapter", format: "umd", minify: true },
|
49 | ].map(config);
|