import ReactDOMServer from "react-dom/server.browser"; addEventListener("fetch", async (event: FetchEvent) => { var route = Wundle.match(event); console.log("Main:", Wundle.main); console.log("cwd:", Wundle.cwd); console.log("Origin:", Wundle.origin); const { default: PageComponent } = await import(route.filePath); // This returns all .css files that were imported in the line above. // It's recursive, so any file that imports a CSS file will be included. const stylesheets = Wundle.getImportedStyles() as string[]; const response = new Response(` ${stylesheets .map((style) => ``) .join("\n")}
${ReactDOMServer.renderToString( )}
`); event.respondWith(response); }); // typescript isolated modules export {}; declare var Wundle: any;