How do I dynamically import .ts files?

I’m working on a tool handler for OpenAI’s ChatGPT and aiming to make the tool system dynamic for easy additions. Currently, my code requires importing files containing tool information, but I’ve encountered an issue with dynamically importing TypeScript files (.ts).

Here’s my code:

// index.ts
(async () => {
    const file = await import('./time');
    console.log(file.configs);
})();
// time.ts
export function exec() {
    return "It is 12:00 AM";   
}

export const configs = {
    name: "get_time",
    description: "Get time for a specified timezone",
    props: {
        time_zone: {
            description: "The time zone you want the time for.",
            type: "string",
            required: true,
        }
    }
}

Here’s the error I run into:

Error: Cannot find module 'C:pathtime' imported from C:pathindex.ts

I attempted altering my tsconfig.json without success. Shifting the environment from Node to Bun was effective, but Bun doesn’t yet support node modules on Windows.

I switched from ts-node index.ts to node --loader ts-node/esm index.ts, which worked too. Yet, I’m unsure if this method is reliable; it appeared prone to errors.

Is there a better approach to handling tools, or is there a way to dynamically import TypeScript tools effectively?