This repository was archived by the owner on Apr 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
106 lines (95 loc) · 2.51 KB
/
Copy pathtsup.config.ts
File metadata and controls
106 lines (95 loc) · 2.51 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 "tsup";
import pkg from "./package.json" with { type: "json" };
const { managerEntries = [], previewEntries = [], nodeEntries = [] } =
pkg.bundler || {};
const external = ["storybook", "react", "react-dom"];
export default defineConfig((options) => {
const configs = [];
if (managerEntries.length) {
configs.push({
entry: managerEntries,
outDir: "dist",
format: ["esm" as const],
target: "esnext" as const,
platform: "browser" as const,
external,
treeshake: true,
...options,
});
}
if (previewEntries.length) {
configs.push({
entry: previewEntries,
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "esnext" as const,
platform: "browser" as const,
external,
dts: true,
treeshake: true,
...options,
});
}
if (nodeEntries.length) {
configs.push({
entry: nodeEntries,
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "node20" as const,
platform: "node" as const,
external,
dts: true,
treeshake: true,
...options,
});
}
// Vitest plugin (node — it's a Vite plugin)
configs.push({
entry: ["./src/vitest-plugin.ts"],
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "node20" as const,
platform: "node" as const,
external,
dts: true,
treeshake: true,
...options,
});
// Vitest setup file (browser — runs in vitest browser context)
configs.push({
entry: ["./src/vitest-setup.ts"],
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "esnext" as const,
platform: "browser" as const,
external: [...external, "vitest", "@accesslint/vitest"],
dts: true,
treeshake: true,
...options,
});
// Custom Vitest matchers (re-export from @accesslint/vitest)
configs.push({
entry: ["./src/matchers.ts"],
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "esnext" as const,
platform: "browser" as const,
external: [...external, "@accesslint/vitest"],
dts: true,
treeshake: true,
...options,
});
// Portable stories helper (browser — used in external test setups)
configs.push({
entry: ["./src/portable.ts"],
outDir: "dist",
format: ["esm" as const, "cjs" as const],
target: "esnext" as const,
platform: "browser" as const,
external,
dts: true,
treeshake: true,
...options,
});
return configs;
});