Repository navigation
Expand file tree
/
Copy pathtsup.config.ts
More file actions
42 lines (41 loc) · 2.17 KB
/
Copy pathtsup.config.ts
File metadata and controls
42 lines (41 loc) · 2.17 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
import { builtinModules } from "node:module";
import { fileURLToPath } from "node:url";
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts", "src/cli.ts", "src/router/index.ts"],
format: ["esm"],
dts: true,
clean: true,
sourcemap: true,
target: "node22",
splitting: false,
noExternal: [/.*/],
external: [...builtinModules.flatMap((m) => [m, `node:${m}`])],
esbuildOptions(options) {
// We and @blockrun/llm depend on each other, and `noExternal` inlines it. Its
// `import { route, ... } from "@blockrun/clawrouter"` therefore resolves through
// node_modules to the LAST PUBLISHED build of this package, and esbuild inlines
// that whole stale bundle beside the one it is building — a second ClawRouter,
// older, with its own module state, growing by one full copy every release
// (3MB -> 10MB in v0.12.220). Point the back-import at our own source so it
// dedupes into the graph instead. scripts/smoke-dist.mjs asserts the copy is gone.
options.alias = {
...options.alias,
"@blockrun/clawrouter": fileURLToPath(new URL("src/index.ts", import.meta.url)),
};
// @blockrun/llm lazy-imports the Anthropic SDK for its own AnthropicClient,
// which ClawRouter never uses. Inlined it is ~0.6MB, including an agent bash
// tool built on child_process; external, it loads from node_modules (an
// @blockrun/llm dependency) in the unlikely case it ever runs. Set here, not
// in `external`: `noExternal: [/.*/]` wins over tsup's own external list.
options.external = [...(options.external ?? []), "@anthropic-ai/sdk"];
},
// The identifier must not be `__cjs_createRequire`: the stale bundle above carries
// its own `import { createRequire as __cjs_createRequire }`, and esbuild cannot
// rename around a banner it never sees (banners are injected as raw text after the
// bundle is built). The duplicate declaration is a load-time SyntaxError that
// bricked the whole CLI in v0.12.220. Keep this name unique to us.
banner: {
js: `import { createRequire as __blockrun_createRequire } from 'node:module'; const require = __blockrun_createRequire(import.meta.url);`,
},
});