aboutsummaryrefslogtreecommitdiff
path: root/bench/react-hello-world/react-hello-world.jsx
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-21 01:00:27 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-21 01:00:27 -0700
commitc4580ee2ca8fb883c5357546edad94bc93026248 (patch)
treee8b59f46f4e7211469cdb5c70b508a46da6c39a4 /bench/react-hello-world/react-hello-world.jsx
parenta8fa61ed68aa677e1a57c24b0fa93a662ee840d9 (diff)
downloadbun-c4580ee2ca8fb883c5357546edad94bc93026248.tar.gz
bun-c4580ee2ca8fb883c5357546edad94bc93026248.tar.zst
bun-c4580ee2ca8fb883c5357546edad94bc93026248.zip
Rename reactdom-bun -> react-dom-server.bun
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}`);