fix: externalize typescript in CLI esbuild bundle

indexer.ts imports typescript directly. Bundling it into an ESM output
causes 'Dynamic require of fs is not supported' because typescript uses
CJS require() for Node built-ins internally.

Marking typescript as external drops the CLI bundle from 9.9 MB to 417 KB
and fixes the startup crash on Node 22.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
SinachPat
2026-05-07 14:32:43 +01:00
co-authored by Claude Sonnet 4.6
parent 8af7dacacc
commit 14e4db6468
+4
View File
@@ -24,6 +24,10 @@ const NODE_BUILTINS = [
'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder',
'sys', 'timers', 'tls', 'trace_events', 'tty', 'url', 'util', 'v8',
'vm', 'worker_threads', 'zlib',
// typescript uses CJS require() for Node built-ins internally — bundling it
// into an ESM output causes "Dynamic require of 'fs' is not supported".
// Leave it external so Node resolves it from node_modules at runtime.
'typescript',
];
// ── html2canvas text-embed plugin ────────────────────────────────────────────