import { dirname, join, relative } from 'node:path'; type TransformModule = (options: Record) => { modules: { code: string; map?: string | null }[]; diagnostics: { category: string; message: string }[]; }; const toPosix = (path: string) => path.replaceAll('\\', '/'); /** Calls of `$()`, `component$()` and `useTask$()`, but not of `$name$()` properties. */ const QRL_MARKER_CALL = /(? d.category === 'error'); if (errors.length) { throw new Error(`${id}: ${errors.map((d) => d.message).join('\n')}`); } const [output] = result.modules; const optimizerImports = relative( dirname(id), join(coreDir, 'shared', 'qrl', 'optimizer-imports') ); const posixPath = toPosix(optimizerImports); const specifier = posixPath.startsWith('.') ? posixPath : `./${posixPath}`; return { code: output.code.replaceAll('from "@qwik.dev/core"', `from "${specifier}"`), map: output.map, }; }