-
Notifications
You must be signed in to change notification settings - Fork 21
/
rollup.config.js
48 lines (43 loc) · 1.14 KB
/
rollup.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
42
43
44
45
46
47
48
import { readFileSync } from "fs";
import { resolve, dirname } from "path";
import { fileURLToPath } from "url";
import nodeResolve from "rollup-plugin-node-resolve";
import { swc } from "rollup-plugin-swc3";
import replace from "rollup-plugin-replace";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const wasmBytes = Array.from(
readFileSync(resolve(__dirname, "src/xxhash.wasm"))
);
const output = [
{
file: "cjs/xxhash-wasm.cjs",
format: "cjs",
sourcemap: true,
exports: "default",
},
{ file: "esm/xxhash-wasm.js", format: "es", sourcemap: true },
{
file: "umd/xxhash-wasm.js",
format: "umd",
name: "xxhash",
sourcemap: true,
},
];
const replacements = {
WASM_PRECOMPILED_BYTES: JSON.stringify(wasmBytes),
};
const swc_config = JSON.parse(
readFileSync(resolve(__dirname, ".swcrc"), "utf-8")
);
export default {
input: "src/index.js",
output,
plugins: [
replace(replacements),
// The config is necessary, because the plugin overwrites some of the settings,
// instead of just falling back to .swcrc
swc(swc_config),
nodeResolve(),
],
};