diff options
-rw-r--r-- | bench/react-hello-world/react-hello-world.jsx | 19 | ||||
-rw-r--r-- | test/bun.js/react-dom-server.bun.js (renamed from test/bun.js/reactdom-bun.js) | 4 | ||||
-rw-r--r-- | test/bun.js/react-dom.test.tsx | 2 |
3 files changed, 16 insertions, 9 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}`); diff --git a/test/bun.js/reactdom-bun.js b/test/bun.js/react-dom-server.bun.js index c489314fb..fc578c8a9 100644 --- a/test/bun.js/reactdom-bun.js +++ b/test/bun.js/react-dom-server.bun.js @@ -7,7 +7,6 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -const escapeHTML = Bun.escapeHTML; var aa = require("react"); function k(a) { for ( @@ -200,8 +199,7 @@ Object.keys(z).forEach(function (a) { }); var ma = /["'&<>]/; function A(a) { - if ("boolean" === typeof a || "number" === typeof a) return "" + a; - return escapeHTML(a); + return Bun.escapeHTML(a); } var na = /([A-Z])/g, oa = /^ms-/, diff --git a/test/bun.js/react-dom.test.tsx b/test/bun.js/react-dom.test.tsx index d204e88e0..42f4c7631 100644 --- a/test/bun.js/react-dom.test.tsx +++ b/test/bun.js/react-dom.test.tsx @@ -10,7 +10,7 @@ import { heapStats } from "bun:jsc"; import { describe, expect, it } from "bun:test"; import { renderToReadableStream as renderToReadableStreamBrowser } from "react-dom/server.browser"; import { gc } from "./gc"; -import { renderToReadableStream as renderToReadableStreamBun } from "./reactdom-bun"; +import { renderToReadableStream as renderToReadableStreamBun } from "./react-dom-server.bun"; import React from "react"; Object.defineProperty(renderToReadableStreamBrowser, "name", { |