commit SGF2311
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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'));
|
||||
}
|
||||
Reference in New Issue
Block a user