-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtsup.config.ts
More file actions
56 lines (54 loc) · 1.53 KB
/
tsup.config.ts
File metadata and controls
56 lines (54 loc) · 1.53 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
import { defineConfig } from "tsup"
import path from "path"
function aliasPlugin(aliases: Record<string, string>) {
return {
name: "alias",
setup(build: any) {
for (const [key, value] of Object.entries(aliases)) {
const filter = new RegExp(`^${key}(?:$|/)`)
build.onResolve({ filter }, (args: any) => {
// Only alias the bare specifier or subpath; map to value for bare specifier
return { path: value }
})
}
},
}
}
export default defineConfig([
{
entry: { index: "./lib/index.ts" },
dts: true,
format: ["esm"],
sourcemap: true,
splitting: false,
clean: true,
},
{
entry: { vanilla: "./lib/vanilla/index.ts" },
dts: true,
format: ["esm"],
sourcemap: true,
splitting: false,
clean: false,
noExternal: ["jscad-fiber", "react", "react-dom", "react/jsx-runtime"],
// Configure esbuild for classic JSX and symbol injection
esbuildOptions(options) {
options.jsxFactory = "h"
options.jsxFragment = "Fragment"
;(options as any).inject = [
path.resolve(__dirname, "lib/vanilla/jsx-inject.ts"),
]
},
esbuildPlugins: [
aliasPlugin({
"jscad-fiber": path.resolve(__dirname, "lib/vanilla/primitives.ts"),
react: path.resolve(__dirname, "lib/vanilla/react-shim.ts"),
"react-dom": path.resolve(__dirname, "lib/vanilla/react-shim.ts"),
"react/jsx-runtime": path.resolve(
__dirname,
"lib/vanilla/react-shim.ts",
),
}),
],
},
])