import {build} from 'vite'; // Compile in memory: render checks do not need the dev server or its SSR transport. // Resolve external packages to file URLs so native imports share React with the test. export async function renderCheckModule(entry) { const result=await build({ configFile:false, logLevel:'error', build:{ ssr:entry, write:false, minify:false, rolldownOptions:{output:{paths:id=>import.meta.resolve(id)}}, }, }); const chunks=result.output.filter(item=>item.type==='chunk'); if(chunks.length!==1)throw new Error('Render check requires a single SSR chunk.'); return import('data:text/javascript;base64,'+Buffer.from(chunks[0].code).toString('base64')); }