-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtsup.binary.config.ts
More file actions
44 lines (41 loc) · 1.44 KB
/
Copy pathtsup.binary.config.ts
File metadata and controls
44 lines (41 loc) · 1.44 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
/**
* ESM bundle for pkg — produces dist/index.mjs with all dependencies inlined.
*
* We keep ESM format (not CJS) because:
* - yoga-layout (used by Ink) uses top-level await + WebAssembly
* - Top-level await is only allowed in ESM; CJS conversion breaks it
*
* react-devtools-core is an optional Ink dependency only loaded in dev mode.
* It's not installed and never called at runtime, so we stub it with an
* empty module via an esbuild plugin.
*/
import { defineConfig } from "tsup";
import type { Plugin } from "esbuild";
/** Replaces react-devtools-core with an empty module stub. */
const stubDevtools: Plugin = {
name: "stub-react-devtools-core",
setup(build) {
build.onResolve({ filter: /react-devtools-core/ }, () => ({
path: "react-devtools-core",
namespace: "stub",
}));
build.onLoad({ filter: /.*/, namespace: "stub" }, () => ({
contents: "export default null;",
}));
},
};
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
target: "node20",
clean: false, // preserve dist/index.js from the npm ESM build
sourcemap: false,
outExtension: () => ({ js: ".mjs" }),
// Bundle every import so pkg gets a single self-contained file
noExternal: [/.*/],
// Single output file — pkg cannot resolve dynamic chunk imports at runtime
splitting: false,
esbuildPlugins: [stubDevtools],
// No shebang — pkg adds the native executable header for each OS
banner: {},
});