forked from wasmerio/wasmer-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
90 lines (82 loc) · 2.03 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Rollup config for the WASI Lib
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import builtins from "rollup-plugin-node-builtins";
import globals from "rollup-plugin-node-globals";
import typescript from "rollup-plugin-typescript2";
import json from "rollup-plugin-json";
import replace from "rollup-plugin-replace";
import compiler from "@ampproject/rollup-plugin-closure-compiler";
import bundleSize from "rollup-plugin-bundle-size";
import pkg from "./package.json";
const sourcemapOption = process.env.PROD ? undefined : "inline";
const replaceNodeOptions = {
delimiters: ["", ""],
values: {
"/*ROLLUP_REPLACE_NODE": "",
"ROLLUP_REPLACE_NODE*/": ""
}
};
const replaceBrowserOptions = {
delimiters: ["", ""],
values: {
"/*ROLLUP_REPLACE_BROWSER": "",
"ROLLUP_REPLACE_BROWSER*/": ""
}
};
let typescriptPluginOptions = {
tsconfig: "../../tsconfig.json",
exclude: ["./test/**/*"],
clean: process.env.PROD ? true : false,
objectHashIgnoreUnknownHack: true
};
const plugins = [
typescript(typescriptPluginOptions),
resolve({ preferBuiltins: true }),
commonjs(),
globals(),
builtins(),
json(),
process.env.PROD ? compiler() : undefined,
process.env.PROD ? bundleSize() : undefined
];
const libBundles = [
{
input: "./src/index.ts",
output: {
file: pkg.module,
format: "esm",
sourcemap: sourcemapOption
},
watch: {
clearScreen: false
},
plugins: [replace(replaceBrowserOptions), ...plugins]
},
{
input: "./src/index.ts",
output: {
file: pkg.iife,
format: "iife",
sourcemap: sourcemapOption,
name: "WASI"
},
watch: {
clearScreen: false
},
plugins: [replace(replaceBrowserOptions), ...plugins]
},
{
input: "./src/index.ts",
output: {
file: pkg.main,
format: "cjs",
sourcemap: sourcemapOption
},
watch: {
clearScreen: false
},
plugins: [replace(replaceNodeOptions), ...plugins]
}
];
export default libBundles;