aboutsummaryrefslogtreecommitdiff
path: root/bench/react-hello-world/react-hello-world.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'bench/react-hello-world/react-hello-world.jsx')
-rw-r--r--bench/react-hello-world/react-hello-world.jsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/bench/react-hello-world/react-hello-world.jsx b/bench/react-hello-world/react-hello-world.jsx
index 15f2b000b..a61ad7567 100644
--- a/bench/react-hello-world/react-hello-world.jsx
+++ b/bench/react-hello-world/react-hello-world.jsx
@@ -1,9 +1,13 @@
-import { renderToReadableStream } from "../../test/bun.js/reactdom-bun.js";
+// to run this:
+// bun react-hello-world.jsx --jsx-production
+// This will become the official react-dom/server.bun build a little later
+// It will be the default when you import from "react-dom/server"
+// That will work via the "bun" package.json export condition (which bun already supports)
+import { renderToReadableStream } from "../../test/bun.js/react-dom-server.bun";
const headers = {
headers: {
"Content-Type": "text/html",
- "Cache-Control": "no-transform", // set to match the Deno benchmark, which requires this for an apples to apples comparison
},
};
@@ -11,12 +15,17 @@ const App = () => (
<html>
<body>
<h1>Hello World</h1>
+ <p>This is an example.</p>
</body>
</html>
);
-export default {
+const port = Number(process.env.PORT || 3001);
+Bun.serve({
+ port,
async fetch(req) {
- return new Response(await renderToReadableStream(<App />), headers);
+ return new Response(await renderToReadableStream(<App />));
},
-};
+});
+
+console.log(`Server running on\n http://localhost:${port}`);