Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): normalize Windows authored external paths (#2030)

vercel-gh-bot-2[bot]891aed806755
diff --git a/.changeset/tidy-windows-paths.md b/.changeset/tidy-windows-paths.md
new file mode 100644
index 000000000..9556aa891
--- /dev/null
+++ b/.changeset/tidy-windows-paths.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Fix authored-module evaluation on Windows when configured external dependencies resolve to absolute paths.
diff --git a/packages/eve/src/internal/authored-package-boundary.test.ts b/packages/eve/src/internal/authored-package-boundary.test.ts
new file mode 100644
index 000000000..66b4510eb
--- /dev/null
+++ b/packages/eve/src/internal/authored-package-boundary.test.ts
@@ -0,0 +1,49 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ createRuntimeLoaderPackageBoundaryPlugin,
+ type RolldownResolveContext,
+} from "#internal/authored-package-boundary.js";
+
+describe("createRuntimeLoaderPackageBoundaryPlugin", () => {
+ it.each([
+ [
+ "C:\\workspace\\app\\node_modules\\external-only\\index.js",
+ "file:///C:/workspace/app/node_modules/external-only/index.js",
+ ],
+ [
+ "\\\\server\\share\\app\\node_modules\\external-only\\index.js",
+ "file://server/share/app/node_modules/external-only/index.js",
+ ],
+ [
+ "/workspace/app/node_modules/external-only/index.js",
+ "/workspace/app/node_modules/external-only/index.js",
+ ],
+ ["external-only", "external-only"],
+ ])("emits resolved external %s as %s", async (resolvedId, expectedId) => {
+ const plugin = createRuntimeLoaderPackageBoundaryPlugin({
+ externalDependencies: ["external-only"],
+ packageRoot: "C:\\workspace\\app",
+ });
+ const resolveId = plugin.resolveId as (
+ this: RolldownResolveContext,
+ source: string,
+ importer: string | undefined,
+ options: { kind: string },
+ ) => Promise<unknown>;
+ const context: RolldownResolveContext = {
+ async resolve() {
+ return { id: resolvedId };
+ },
+ };
+
+ await expect(
+ resolveId.call(context, "external-only", "C:\\workspace\\app\\agent\\tools\\ping.ts", {
+ kind: "import-statement",
+ }),
+ ).resolves.toEqual({
+ external: true,
+ id: expectedId,
+ });
+ });
+});
diff --git a/packages/eve/src/internal/authored-package-boundary.ts b/packages/eve/src/internal/authored-package-boundary.ts
index 120e97cdb..2c470f842 100644
--- a/packages/eve/src/internal/authored-package-boundary.ts
+++ b/packages/eve/src/internal/authored-package-boundary.ts
@@ -2,6 +2,8 @@ import { existsSync, readFileSync, realpathSync } from "node:fs";
import { isBuiltin } from "node:module";
import { dirname, join, resolve, sep } from "node:path";
+import { normalizeEsmImportSpecifier } from "#internal/application/import-specifier.js";
+
export const CACHED_CHANNEL_PREFIX = "eve-cached-channel:";
export const RESOLVE_EXTENSIONS = [
@@ -102,10 +104,12 @@ export function createRuntimeLoaderPackageBoundaryPlugin(input: {
source,
});
if (externalModule !== undefined) {
+ const resolvedId =
+ resolveExistingExternalFilePath(externalModule.resolvedId) ?? externalModule.resolvedId;
+
return {
external: true,
- id:
- resolveExistingExternalFilePath(externalModule.resolvedId) ?? externalModule.resolvedId,
+ id: normalizeEsmImportSpecifier(resolvedId),
};
}