-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsup.config.ts
More file actions
67 lines (66 loc) · 2.4 KB
/
Copy pathtsup.config.ts
File metadata and controls
67 lines (66 loc) · 2.4 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
import { defineConfig } from "tsup";
// Two committed, reproducible artifacts (verified by `pnpm run check:build`):
// - scripts/engine.mjs (+ engine.d.mts): the zero-dependency library bundle
// consumers vendor; tsup inlines web-tree-sitter's JS, so the only optional
// sidecar is scripts/grammars/ (wasm — regex tier without it).
// - scripts/cli.mjs: the thin standalone CLI/MCP wrapper. The engine import
// stays EXTERNAL (resolved to the sibling engine.mjs at runtime) so the
// library is not duplicated inside the wrapper.
// - scripts/engine.browser.mjs (+ engine.browser.d.mts): the same engine
// resolved against browser shims, published as `@maxgfr/codeindex/browser`.
// Its JAVASCRIPT is built by scripts/build-browser.mjs, not here: that build
// has to intercept the resolution of node builtins, and tsup registers its
// own node-protocol plugin ahead of user plugins — first onResolve result
// wins, so the interception has to own the plugin list outright. Its TYPES
// are emitted here, because they are ordinary TypeScript declarations with
// no such constraint, and hand-writing them would guarantee drift.
export default defineConfig([
{
entry: { engine: "src/engine.ts" },
outDir: "scripts",
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
target: "node18",
platform: "node",
bundle: true,
dts: true,
clean: false,
minify: false,
splitting: false,
sourcemap: false,
banner: { js: "#!/usr/bin/env node" },
},
{
entry: { cli: "src/cli-entry.ts" },
outDir: "scripts",
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
target: "node18",
platform: "node",
bundle: true,
dts: false,
clean: false,
minify: false,
splitting: false,
sourcemap: false,
banner: { js: "#!/usr/bin/env node" },
esbuildPlugins: [
{
name: "external-engine",
setup(build) {
build.onResolve({ filter: /^\.\/engine\.js$/ }, () => ({ path: "./engine.mjs", external: true }));
},
},
],
},
{
// Declarations only — the JS for this entry comes from
// scripts/build-browser.mjs. Same public surface as engine.d.mts plus the
// VFS and grammar-loading API the browser build adds.
entry: { "engine.browser": "src/browser/entry.ts" },
outDir: "scripts",
format: ["esm"],
dts: { only: true },
clean: false,
},
]);