-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
46 lines (39 loc) · 1.2 KB
/
tsup.config.ts
File metadata and controls
46 lines (39 loc) · 1.2 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
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
outDir: "dist",
format: ["cjs"], // Works great with Electron
dts: true,
external: ["node-swift"],
clean: true,
sourcemap: true,
splitting: false, // Keep false for native modules
target: "node16",
platform: "node",
bundle: true,
minify: false, // Keep false for native modules to avoid issues
keepNames: true,
skipNodeModulesBundle: true,
noExternal: [], // Don't bundle any external deps
// Handle .node files (copy them as-is)
loader: {
".node": "copy",
},
banner: {
js: "// Generated by tsup - Node-Accessibility Native Module",
},
define: {
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "production"),
},
esbuildOptions: (options) => {
options.keepNames = true; // Preserve original function names for native interop
options.platform = "node";
// Don't resolve .node files
options.external = options.external || [];
options.external.push("*.node");
},
onSuccess: async () => {
console.log("✅ TypeScript build completed successfully!");
console.log("💡 Remember to run copy:native to bundle Module.node");
},
});