aboutsummaryrefslogtreecommitdiff
path: root/demos/css-stress-test/framework.tsx
blob: 22b1a31098df23681bf272726b4e7bb0abceb9e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import ReactDOMServer from "react-dom/server.browser";

addEventListener("fetch", async (event: FetchEvent) => {
  var route = Wundle.match(event);
  console.log("Route", JSON.stringify(route.query, null, 2));
  const { default: PageComponent } = await import(route.filepath);
  // const router = Wundle.Router.match(event);
  // console.log("Route", router.name);

  // const { Base: Page } = await router.import();

  const response = new Response(`
  <!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="./src/index.css" />
    <link
      rel="stylesheet"
      crossorigin="anonymous"
      href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&family=Space+Mono:wght@400;700"
    />
  </head>
  <body>
    <link rel="stylesheet" href="./src/index.css" />
    <div id="reactroot">${ReactDOMServer.renderToString(
      <PageComponent />
    )}</div>

    <script src="./src/index.tsx" async type="module"></script>
  </body>
</html>
  `);

  event.respondWith(response);
});

// typescript isolated modules
export {};