-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
106 lines (104 loc) · 2.56 KB
/
vite.config.ts
File metadata and controls
106 lines (104 loc) · 2.56 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { defineConfig } from "vitest/config";
import dts from "vite-plugin-dts";
import tsconfigPaths from "vite-tsconfig-paths";
import pkg from "./package.json";
const isCliBuild = process.env.BUILD_TARGET === "cli";
const isCI = process.env.CI === "true";
export default defineConfig({
define: {
__VERSION__: JSON.stringify(pkg.version),
},
// Use cacheDir only for Vitest, not for build
cacheDir: process.env.VITEST ? "node_modules/.vitest" : undefined,
plugins: isCliBuild
? []
: [
dts({
include: ["src/**/*"],
exclude: ["src/cli.ts", "**/*.diagnostic.test.ts"],
outDir: "dist",
}),
],
build: isCliBuild
? {
// CLI build: ESM only
lib: {
entry: "src/cli.ts",
fileName: () => "cli.js",
formats: ["es"],
},
outDir: "dist",
emptyOutDir: false,
target: "node18",
modulePreload: false,
rollupOptions: {
external: (id: string) => id.startsWith("node:") || id.startsWith("ppef"),
},
}
: {
// Library build: ES, CJS, UMD
lib: {
entry: "src/index.ts",
name: "GraphBox",
fileName: (format) => {
const extensions: Record<string, string> = {
es: "index.js",
cjs: "index.cjs",
umd: "index.umd.js",
};
return extensions[format] ?? `index.${format}.js`;
},
formats: ["es", "cjs", "umd"],
},
outDir: "dist",
emptyOutDir: true,
target: "ES2022",
modulePreload: false,
rollupOptions: {
// Externalize Node.js modules for browser compatibility
external: (id: string) =>
id.startsWith("node:") ||
id.startsWith("ppef") ||
id.includes("/experiments/evaluation/fixtures/") ||
id.includes("/experiments/evaluation/loaders/"),
},
},
test: {
globals: true,
environment: "node",
fileParallelism: false,
testTimeout: 30000,
exclude: ["node_modules", "dist"],
coverage: {
provider: "v8",
reporter: isCI ? ["text", "json", "html"] : ["text"],
include: ["src/**/*.ts"],
exclude: ["src/**/*.test.ts", "src/**/*.spec.ts", "src/**/fixtures/**"],
// Coverage thresholds — set just below current actuals to prevent regressions
thresholds: {
lines: 70,
functions: 70,
branches: 65,
statements: 70,
},
},
projects: [
{
plugins: [tsconfigPaths()],
test: {
name: "exp",
include: ["src/**/*.exp.*.test.ts"],
testTimeout: 30_000,
},
},
{
plugins: [tsconfigPaths()],
test: {
name: "unit",
include: ["src/**/*.unit.test.ts", "src/**/*.integration.test.ts"],
testTimeout: 30_000,
},
},
],
},
});