[PR #489] [MERGED] fix(deepagents): handle Windows absolute paths in tsdown external filter #503

Closed
opened 2026-06-05 17:23:28 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/489
Author: @sukhmanghotraa
Created: 4/26/2026
Status: Merged
Merged: 4/27/2026
Merged by: @hntrl

Base: mainHead: fix/windows-tsdown-external-paths


📝 Commits (2)

  • 0ddb70c fix(deepagents): handle Windows absolute paths in tsdown external filter
  • cf21f8b cr

📊 Changes

8 files changed (+24 additions, -13 deletions)

View changed files

📝 internal/eval-harness/tsdown.config.ts (+3 -1)
📝 libs/acp/tsdown.config.ts (+3 -2)
📝 libs/deepagents/tsdown.config.ts (+3 -2)
📝 libs/providers/daytona/tsdown.config.ts (+3 -2)
📝 libs/providers/deno/tsdown.config.ts (+3 -2)
📝 libs/providers/modal/tsdown.config.ts (+3 -2)
📝 libs/providers/quickjs/tsdown.config.ts (+3 -1)
📝 libs/standard-tests/tsdown.config.ts (+3 -1)

📄 Description

Fix: ERR_MODULE_NOT_FOUND on Windows when building deepagents

Problem

Building libs/deepagents on Windows produces a dist/index.js that imports
local modules with .ts extensions instead of bundling them:

import { createDeepAgent } from "./agent.ts";
import { ConfigurationError } from "./errors.ts";

This causes an immediate crash at runtime for any consumer of the library:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  'C:\...\deepagentsjs\libs\deepagents\dist\agent.ts'
  imported from C:\...\deepagentsjs\libs\deepagents\dist\index.js

Root Cause
The external filter in libs/deepagents/tsdown.config.ts: used a regex intended to match
only npm package names (which don't start with . or /):

const external = [/^[^./]/];

On Unix absolute paths start with / so the regex correctly excludes them. On Windows absolute paths start with a drive letter (e.g. C:...), which also doesn't start with . or / - so rolldown matches them as external, excludes them from the bundle, and leaves raw .ts references in the output.

Fix
Replace the regex with a function that explicitly excludes Windows-style
absolute paths:

const external = (id: string) =>
  !id.startsWith(".") && !id.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(id);

After this change pnpm -w run build in libs/deepagents produces a fully
bundled [dist/index.js] with no .ts imports and examples run correctly on Windows.

Notes

  • deps.neverBundle (the tsdown-recommended replacement for [external] is not yet functional in tsdown 0.21.7 / rolldown 1.0.0-rc.12 and causes a build error. This fix is the correct workaround until that API stabilises.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/489 **Author:** [@sukhmanghotraa](https://github.com/sukhmanghotraa) **Created:** 4/26/2026 **Status:** ✅ Merged **Merged:** 4/27/2026 **Merged by:** [@hntrl](https://github.com/hntrl) **Base:** `main` ← **Head:** `fix/windows-tsdown-external-paths` --- ### 📝 Commits (2) - [`0ddb70c`](https://github.com/langchain-ai/deepagentsjs/commit/0ddb70cfdf7c3b30ee49f39150afc0f446c5915b) fix(deepagents): handle Windows absolute paths in tsdown external filter - [`cf21f8b`](https://github.com/langchain-ai/deepagentsjs/commit/cf21f8bc39c71c279f1c0941f4ffaa2459c71c55) cr ### 📊 Changes **8 files changed** (+24 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `internal/eval-harness/tsdown.config.ts` (+3 -1) 📝 `libs/acp/tsdown.config.ts` (+3 -2) 📝 `libs/deepagents/tsdown.config.ts` (+3 -2) 📝 `libs/providers/daytona/tsdown.config.ts` (+3 -2) 📝 `libs/providers/deno/tsdown.config.ts` (+3 -2) 📝 `libs/providers/modal/tsdown.config.ts` (+3 -2) 📝 `libs/providers/quickjs/tsdown.config.ts` (+3 -1) 📝 `libs/standard-tests/tsdown.config.ts` (+3 -1) </details> ### 📄 Description ## Fix: `ERR_MODULE_NOT_FOUND` on Windows when building `deepagents` ### Problem Building `libs/deepagents` on Windows produces a `dist/index.js` that imports local modules with `.ts` extensions instead of bundling them: ```js import { createDeepAgent } from "./agent.ts"; import { ConfigurationError } from "./errors.ts"; ``` This causes an immediate crash at runtime for any consumer of the library: ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\...\deepagentsjs\libs\deepagents\dist\agent.ts' imported from C:\...\deepagentsjs\libs\deepagents\dist\index.js ``` **Root Cause** The `external` filter in `libs/deepagents/tsdown.config.ts:` used a regex intended to match only npm package names (which don't start with `.` or `/`): ```js const external = [/^[^./]/]; ``` On Unix absolute paths start with `/` so the regex correctly excludes them. On Windows absolute paths start with a drive letter (e.g. C:\...), which also doesn't start with `.` or `/` - so rolldown matches them as external, excludes them from the bundle, and leaves raw `.ts` references in the output. **Fix** Replace the regex with a function that explicitly excludes Windows-style absolute paths: ```js const external = (id: string) => !id.startsWith(".") && !id.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(id); ``` After this change `pnpm -w run build` in `libs/deepagents` produces a fully bundled `[dist/index.js]` with no `.ts` imports and examples run correctly on Windows. Notes - `deps.neverBundle` (the tsdown-recommended replacement for `[external]` is not yet functional in tsdown 0.21.7 / rolldown 1.0.0-rc.12 and causes a build error. This fix is the correct workaround until that API stabilises. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:23:28 -04:00
yindo closed this issue 2026-06-05 17:23:29 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#503