diff --git a/server/src/adapters/plugin-loader.ts b/server/src/adapters/plugin-loader.ts index a9f704635d..c01fedeac4 100644 --- a/server/src/adapters/plugin-loader.ts +++ b/server/src/adapters/plugin-loader.ts @@ -11,6 +11,7 @@ import fs from "node:fs"; import path from "node:path"; +import { pathToFileURL } from "node:url"; import type { ServerAdapterModule } from "./types.js"; import { logger } from "../middleware/logger.js"; @@ -177,7 +178,7 @@ export async function loadExternalAdapterPackage( logger.info({ packageName, packageDir, entryPoint, modulePath, hasUiParser: !!uiParserSource }, "Loading external adapter package"); - const mod = await import(modulePath); + const mod = await import(pathToFileURL(modulePath).href); const adapterModule = validateAdapterModule(mod, packageName); if (uiParserSource) { @@ -212,7 +213,7 @@ export async function reloadExternalAdapter( const packageDir = resolvePackageDir(record); const entryPoint = resolvePackageEntryPoint(packageDir); const modulePath = path.resolve(packageDir, entryPoint); - const fileUrl = `file://${modulePath}`; + const fileUrl = pathToFileURL(modulePath).href; // Bust ESM module cache so re-import loads fresh code from disk. // Query-string trick (?t=...) works in Node; Bun may need the file:// URL