fully-react
Version:
React Server for Vite
13 lines (10 loc) • 1.81 kB
JavaScript
import u from 'node:path';
import { jsx, Fragment } from 'react/jsx-runtime';
async function p(s,o,r){let n=[];async function t(e){r.has(e)||(r.add(e),await p(s,e,r));}async function i(e){let l=await s.moduleGraph.getModuleByUrl(e);l&&await t(l);}o.ssrTransformResult?o.ssrTransformResult.deps&&o.ssrTransformResult.deps.forEach(e=>n.push(i(e))):o.importedModules.forEach(e=>n.push(t(e))),await Promise.all(n);}var m=/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;async function d(s,o){let r={},n=new Set;try{for(let t of o){let i=await s.pluginContainer.resolveId(t);if(!i){console.log("not found");continue}let e=i.id,l=u.resolve(e).replace(/\\/g,"/"),a=s.moduleGraph.getModuleById(l);if(!a){let c=u.resolve(t);if(await s.ssrLoadModule(c),a=await s.moduleGraph.getModuleByUrl(c),!a){console.log("not found");return}}await p(s,a,n);}}catch{}for(let t of n){new URL(t.url,"http://localhost/").searchParams;if(m.test(t.file??""))try{let l=await s.ssrLoadModule(t.url);r[t.url]=l.default;}catch{}}return r}var _=import.meta.env.DEV?async function(o){let{default:r}=await import('./dev-server-RTWPNS5O.js'),n=await d(r,o.entries??["~/root.tsx"]);return jsx(Fragment,{children:Object.entries(n??{}).map(([t,i])=>jsx("style",{dangerouslySetInnerHTML:{__html:i},suppressHydrationWarning:!0},t))})}:()=>null;var S=import.meta.env.DEV?function(){return import.meta.env.DEV?jsx("script",{type:"module",dangerouslySetInnerHTML:{__html:`
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
`}}):null}:()=>null;
export { _ as InlineStyles, S as ReactRefreshScript, d as collectStyles };