import type { LoadedSource } from "../types/source.types.ts"; import { isObject } from "../predicates/schema.predicate.ts"; import { pathToFileURL } from "node:url"; export const importSource = async function importSource(file: string): Promise { try { const loaded: unknown = await import(pathToFileURL(file).href); return { error: null, exports: isObject(loaded) ? loaded : {}, file }; } catch (error) { return { error: String(error), exports: null, file }; } }; export const importSources = async function importSources(files: readonly string[]): Promise { return Promise.all(files.map(importSource)); };