From 14e4db6468e3c5b9efe8ca25588ed78d9f170c61 Mon Sep 17 00:00:00 2001 From: SinachPat Date: Thu, 7 May 2026 14:32:43 +0100 Subject: [PATCH] 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 --- packages/cli/build.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/build.mjs b/packages/cli/build.mjs index 09436e5..7721449 100644 --- a/packages/cli/build.mjs +++ b/packages/cli/build.mjs @@ -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 ────────────────────────────────────────────