forked from peggyjs/peggy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
115 lines (102 loc) · 2.66 KB
/
rollup.config.mjs
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import commonjs from "@rollup/plugin-commonjs";
import { glob } from "glob";
import ignore from "rollup-plugin-ignore";
import json from "@rollup/plugin-json";
import multiEntry from "@rollup/plugin-multi-entry";
import nodeResolve from "@rollup/plugin-node-resolve";
/**
* @type {import('rollup').RollupOptions}
*/
const umd_config = {
onwarn(message) {
// Avoid this warning: "Use of eval is strongly discouraged, as it poses
// security risks and may cause issues with minification"
if (message.code === "EVAL") {
return;
}
console.error(message);
},
input: "build/ts/lib/peg.js",
output: {
file : "build/rollup/peggy.umd.js",
format : "umd",
name : "peggy",
},
plugins : [
nodeResolve({
mainFields : ["browser", "module", "main"],
browser : true,
extensions : [".js", ".json", ".ts", ".tsx"],
preferBuiltins : false,
}),
commonjs(),
],
};
/**
* @type {import('rollup').RollupOptions}
*/
const browser_test_config = {
onwarn(message) {
// Avoid this warning: "Use of eval is strongly discouraged, as it poses
// security risks and may cause issues with minification"
if (message.code === "EVAL") {
return;
}
console.error(message);
},
input: glob.sync("build/ts/test/**/*.spec.js").sort(),
output: {
file : "build/rollup/test.umd.js",
format : "umd",
name : "browser",
globals: {
"chai": "chai",
"whatwg-url": "whatwgURL",
},
},
external: ["chai", "whatwg-url"],
plugins : [
ignore(["fs", "os", "path", "tty", "url", "util"]),
json(),
nodeResolve({
mainFields : ["browser", "module", "main"],
browser : true,
extensions : [".js", ".json", ".ts", ".tsx"],
preferBuiltins : false,
}),
commonjs(),
multiEntry(),
],
};
/**
* @type {import('rollup').RollupOptions}
*/
const browser_benchmark_config = {
onwarn(message) {
// Avoid this warning: "Use of eval is strongly discouraged, as it poses
// security risks and may cause issues with minification"
if (message.code === "EVAL") {
return;
}
console.error(message);
},
input: "build/ts/benchmark/browser.stub.js",
output: {
file : "build/rollup/benchmark.umd.js",
format : "umd",
name : "browser",
},
plugins : [
nodeResolve({
mainFields : ["browser", "module", "main"],
browser : true,
extensions : [".js", ".json", ".ts", ".tsx"],
preferBuiltins : false,
}),
commonjs(),
],
};
const all = [
umd_config, browser_test_config, browser_benchmark_config,
];
export default all;