You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typechat/ts cannot be bundled for the browser: node:module import in the public validator entrypoint #534
The public typechat/ts entrypoint transitively imports node:module (via createRequire). Bundlers targeting the browser cannot resolve that module, so
an application that imports typechat/ts cannot be built for a web target.
git log -S "node:module" -- typescript/src/ts/validate.ts points to commit 83caa1242d9a9a707a4a66bfbc5fe6174cbcb8dc ("Update Node.js version and
dependencies, remove EOL versions (#428)", 2026-08-21). The import is present
in the current revision
(a89f12602bd3d5ce3805e41a2c337cd6bdb95693), so the public entrypoint has
been unbundleable for browser targets since that change.
Expected behavior
Bundling the typechat/ts entrypoint for a browser target should succeed, or
the package should expose a browser-safe entrypoint for that export.
Actual behavior
git clone https://github.com/microsoft/TypeChat.git
cd TypeChat && git checkout a89f12602bd3d5ce3805e41a2c337cd6bdb95693
cd typescript
npm ci
npm run build
npx esbuild dist/ts/index.js --bundle --platform=browser --format=esm \
--outfile=/tmp/browser-ts.js
✘ [ERROR] Could not resolve "node:module"
dist/ts/validate.js:4:30
4 │ const node_module_1 = require("node:module");
╵ ~~~~~~~~~~~~~
The package "node:module" wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use "--platform=node"
to do that, which will remove this error.
The same entrypoint bundles successfully with --platform=node --format=cjs
(output: 19,275 bytes), confirming the failure is specific to browser targets.
Suggested fix
Add a "browser" condition to the exports map that points at a build
without node:module, keeping the Node build as the default; or
resolve the TypeScript compiler lazily through a small Node-only shim so the typechat/ts module graph stays browser-resolvable.
Activity