-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrolldown.config.js
More file actions
79 lines (72 loc) · 1.8 KB
/
rolldown.config.js
File metadata and controls
79 lines (72 loc) · 1.8 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
import fs from "node:fs";
import path from "node:path";
import { defineConfig } from "rolldown";
import { dts } from "rolldown-plugin-dts";
const packagesDir = path.resolve("./packages");
const packageDir = path.resolve(packagesDir, process.env.TARGET);
const inputPath = path.resolve(packageDir, `src/main.ts`);
const outputPath = path.resolve(packageDir, `dist`);
const targetPkgJson = JSON.parse(
fs.readFileSync(path.resolve(packageDir, "package.json"), "utf-8"),
);
const externalSet = new Set([/^node:/]);
Object.keys({
...(targetPkgJson.dependencies || {}),
...(targetPkgJson.peerDependencies || {}),
}).forEach((key) => externalSet.add(new RegExp(`^${key}(/.*)?$`)));
const commonConfig = {
tsconfig: "./tsconfig.json",
transform: {
target: "node22",
},
platform: "node",
external: [...externalSet],
resolve: {
alias: {
raknet: path.resolve(process.cwd(), "packages/raknet/src/"),
core: path.resolve(process.cwd(), "packages/core/src/"),
filterscript: path.resolve(process.cwd(), "packages/filterscript/src/"),
shared: path.resolve(process.cwd(), "packages/shared/src/"),
},
},
};
export default defineConfig([
{
...commonConfig,
input: {
bundle: inputPath,
},
output: [
{
dir: outputPath,
cleanDir: true,
entryFileNames: "[name].mjs",
format: "es",
minify: true,
},
{
dir: outputPath,
entryFileNames: "[name].js",
format: "cjs",
minify: true,
},
],
},
{
...commonConfig,
input: {
bundle: inputPath,
},
output: {
format: "es",
dir: outputPath,
},
plugins: [
dts({
emitDtsOnly: true,
tsconfig: "./tsconfig.json",
resolve: ["@infernus/streamer"],
}),
],
},
]);