/** Resolves a relative import without an extension to its `.ts` file or folder `index.ts`. */ import { existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; export async function resolve(specifier, context, nextResolve) { if (/^\.\.?\//.test(specifier) && !/\.[cm]?[jt]s$/.test(specifier) && context.parentURL) { for (const suffix of ['.ts', '/index.ts']) { const url = new URL(specifier + suffix, context.parentURL); if (existsSync(fileURLToPath(url))) return nextResolve(url.href, context); } } return nextResolve(specifier, context); }