fix(core): use file:// URLs for local dynamic import() on Windows+Node (#23639)

This commit is contained in:
Luke Parker
2026-04-21 17:54:53 +10:00
committed by GitHub
parent 224548d87d
commit 92c005866b
2 changed files with 8 additions and 4 deletions

View File

@@ -157,9 +157,9 @@ export const layer: Layer.Layer<
if (matches.length) yield* config.waitForDependencies()
for (const match of matches) {
const namespace = path.basename(match, path.extname(match))
const mod = yield* Effect.promise(
() => import(process.platform === "win32" ? match : pathToFileURL(match).href),
)
// `match` is an absolute filesystem path from `Glob.scanSync(..., { absolute: true })`.
// Import it as `file://` so Node on Windows accepts the dynamic import.
const mod = yield* Effect.promise(() => import(pathToFileURL(match).href))
for (const [id, def] of Object.entries<ToolDefinition>(mod)) {
custom.push(fromPlugin(id === "default" ? namespace : `${namespace}_${id}`, def))
}