-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
72 lines (70 loc) · 2.18 KB
/
tsup.config.ts
File metadata and controls
72 lines (70 loc) · 2.18 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
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 = [
"openai",
"js-tiktoken",
"html-to-text",
"@googlemaps/google-maps-services-js",
"react",
"react-dom",
"react/jsx-runtime",
"@vis.gl/react-google-maps",
]
/**
* We build in two stages:
*
* 1. Core entries (no React) — cleans `dist/` first.
* 2. React entry — same `dist/` folder, but with a `"use client"` banner so
* the output can be imported from React Server Components in Next.js
* without a directive-stripping error. `clean: false` so it doesn't wipe
* the output of stage 1.
*
* tsup processes array-form configs sequentially, so stage 1 always runs
* before stage 2.
*/
export default defineConfig([
{
name: "core",
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",
},
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
clean: true,
treeshake: true,
splitting: false,
target: "es2022",
outDir: "dist",
external: EXTERNAL,
},
{
name: "react",
entry: { "react/index": "src/react/index.tsx" },
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
clean: false,
treeshake: true,
splitting: false,
target: "es2022",
outDir: "dist",
external: EXTERNAL,
// Next.js / React Server Components require a `"use client"`
// directive at the top of any client bundle. tsup/esbuild drops
// source-level directives and silently tree-shakes banner strings
// that look like directives, so prepend it as a post-build step.
onSuccess: "node scripts/add-use-client.mjs",
},
])