This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.mjs
93 lines (83 loc) · 2.09 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
import { readdirSync, statSync } from "fs";
import replace from "@rollup/plugin-replace";
import typescript from "rollup-plugin-typescript2";
import cleanup from "rollup-plugin-cleanup";
import prettier from "rollup-plugin-prettier";
import packageJson from "./package.json" assert { type: "json" };
import prettierConfig from "./.prettierrc.json" assert { type: "json" };
const nodeInput = ["./src/index.ts"];
for (const directory of readdirSync("./src/apis")) {
const path = `./src/apis/${directory}`;
if (!statSync(path).isDirectory()) continue;
const file = `${path}/index.ts`;
nodeInput.push(file);
}
const output = {
compact: true,
generatedCode: {
constBindings: true,
arrowFunctions: true,
objectShorthand: true
},
externalLiveBindings: false,
minifyInternalExports: true
};
/** @type {import('rollup').RollupOptions} */
const configNode = {
input: nodeInput,
external: ["crypto", "axios"],
output: [
{
dir: "./dist",
format: "commonjs",
exports: "named",
preserveModules: true,
entryFileNames: "[name].js",
...output
},
{
dir: "./dist",
format: "module",
exports: "named",
preserveModules: true,
entryFileNames: "[name].mjs",
...output
}
],
treeshake: {
unknownGlobalSideEffects: false,
moduleSideEffects: false,
correctVarValueBeforeDeclaration: false,
preset: "smallest",
annotations: false,
propertyReadSideEffects: false
},
plugins: [
typescript({
tsconfig: "./tsconfig.json",
tsconfigOverride: {
compilerOptions: {
module: "ESNext"
}
}
}),
replace({
values: {
"process.env.USER_AGENT_STRING": JSON.stringify(
`${packageJson.name}/${packageJson.version} (+https://npmjs.com/package/${packageJson.name})`
)
},
preventAssignment: true
}),
cleanup({
extensions: ["js", "ts", "mjs"],
comments: ["jsdoc"],
compactComments: true
}),
prettier({
...prettierConfig,
parser: "babel-ts"
})
]
};
export default [configNode];