Repository navigation
Expand file tree
/
Copy pathtsup.config.ts
More file actions
54 lines (52 loc) · 1.72 KB
/
Copy pathtsup.config.ts
File metadata and controls
54 lines (52 loc) · 1.72 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
import { defineConfig } from "tsup"
/**
* Heavy optional-peer deps must never be bundled into our dist — the
* consumer is expected to install them only if they use the corresponding
* subpath.
*/
const EXTERNAL = [
"zod",
"openai",
"@anthropic-ai/sdk",
"js-tiktoken",
"html-to-text",
"@googlemaps/google-maps-services-js",
"react",
"react-dom",
"react/jsx-runtime",
"@vis.gl/react-google-maps",
]
/**
* Single tsup pass that emits every subpath in one go. We previously split
* the React entry into a separate config block but discovered that tsup's
* multi-config mode runs stages in parallel, and the core stage's `clean`
* would race the react stage's output — sometimes wiping the .d.ts files.
*
* The `"use client"` directive that Next.js requires at the top of any
* bundled client module is prepended post-build via the `onSuccess` hook
* (esbuild silently tree-shakes source-level directives and `banner` options
* that look like directives, so source-level alternatives are unreliable).
*/
export default defineConfig({
entry: {
index: "src/index.ts",
"utils/index": "src/utils/index.ts",
"types/index": "src/types/index.ts",
"scrape/index": "src/scrape/index.ts",
"search/index": "src/search/index.ts",
"ai/index": "src/ai/index.ts",
"geocoding/index": "src/geocoding/index.ts",
"generate/index": "src/generate/index.ts",
"react/index": "src/react/index.tsx",
},
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
clean: true,
treeshake: true,
splitting: false,
target: "es2022",
outDir: "dist",
external: EXTERNAL,
onSuccess: "node scripts/add-use-client.mjs",
})