-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathrolldown.config.js
More file actions
84 lines (78 loc) · 1.96 KB
/
Copy pathrolldown.config.js
File metadata and controls
84 lines (78 loc) · 1.96 KB
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
import { defineConfig } from "rolldown";
import { bundle } from "./tools/bundle.cjs";
const outro = bundle.outro();
const EXTENSION = {
esm: "esm.js", //TODO Change it to mjs
cjs: "cjs",
iife: "iife.js",
};
/**
* Get the rolldown config based on the arguments
* @param {"esm" | "cjs" | "iife"} format format of the bundle
* @param {boolean} minified should it be minified
*/
function getConfigForFormat(format, minified = false) {
const extension = EXTENSION[format];
return {
file: minified ? `dist/o_spreadsheet.${format}.min.js` : `dist/o_spreadsheet.${extension}`,
format,
name: "o_spreadsheet",
extend: true,
globals: { "@odoo/owl": "owl", "chart.js": "Chart" },
outro,
banner: bundle.jsBanner(),
minify: minified,
};
}
function onLog(level, log, defaultHandler) {
if (level === "warn") {
// escalate all warnings to errors
defaultHandler("error", log);
} else {
defaultHandler(level, log);
}
}
export default defineConfig((cliArgs) => {
const format = cliArgs.format;
if (format) {
// Only build one version to improve speed
return {
input: "src/index.ts",
external: ["@odoo/owl", "chart.js", "luxon"],
checks: {
circularDependency: true,
},
onLog,
plugins: [],
output: {
name: "o_spreadsheet",
extend: true,
outro,
banner: bundle.jsBanner(),
globals: { "@odoo/owl": "owl", "chart.js": "Chart", luxon: "luxon" },
file: `build/o_spreadsheet.${format}.js`,
format,
sourcemap: true,
},
watch: {
include: ["src/**"],
},
};
}
// dist build
return {
input: "src/index.ts",
external: ["@odoo/owl", "chart.js", "luxon"],
checks: {
circularDependency: true,
},
plugins: [],
onLog,
output: [
getConfigForFormat("esm"),
getConfigForFormat("cjs"),
getConfigForFormat("iife"),
getConfigForFormat("iife", true),
],
};
});