-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
51 lines (47 loc) · 1.75 KB
/
Copy pathtsup.config.ts
File metadata and controls
51 lines (47 loc) · 1.75 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
import { defineConfig } from "tsup";
import { readdirSync } from "fs";
import path from "path";
const root = import.meta.dirname;
const styledSystem = path.resolve(root, "src/styled-system");
// Every component folder becomes its own subpath entry (e.g. "button" ->
// dist/button.js) so consumers can import just what they use, instead of
// paying for the whole barrel's JS and type surface.
function componentEntries(groupDir: string): Record<string, string> {
const entries: Record<string, string> = {};
for (const name of readdirSync(path.join(root, "src/components", groupDir), { withFileTypes: true })) {
if (!name.isDirectory()) continue;
entries[name.name] = `src/components/${groupDir}/${name.name}/index.ts`;
}
return entries;
}
const entry: Record<string, string> = {
index: "src/index.ts",
preset: "src/preset.ts",
provider: "src/provider/index.ts",
...componentEntries("base"),
...componentEntries("docs"),
...componentEntries("landing"),
};
export default defineConfig({
entry,
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
clean: true,
treeshake: true,
splitting: false,
tsconfig: "tsconfig.build.json",
external: ["react", "react-dom", "@ark-ui/react", "@pandacss/dev"],
esbuildOptions(options) {
options.alias = {
// Styled-system sub-paths — map explicitly to .mjs indexes
// because esbuild does not look for index.mjs in directories by default.
"@styled-system/css": `${styledSystem}/css/index.mjs`,
"@styled-system/patterns": `${styledSystem}/patterns/index.mjs`,
"@styled-system/tokens": `${styledSystem}/tokens/index.mjs`,
"@styled-system/jsx": `${styledSystem}/jsx/index.mjs`,
"@styled-system": styledSystem,
"@": path.resolve(root, "src"),
};
},
});