Skip to content

Navigation Menu

Sign in
Sign up

Commit c4580ee

Browse files
Rename reactdom-bun -> react-dom-server.bun
1 parent a8fa61e commit c4580ee

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
import { renderToReadableStream } from "../../test/bun.js/reactdom-bun.js";
1+
// to run this:
2+
// bun react-hello-world.jsx --jsx-production
23

4+
// This will become the official react-dom/server.bun build a little later
5+
// It will be the default when you import from "react-dom/server"
6+
// That will work via the "bun" package.json export condition (which bun already supports)
7+
import { renderToReadableStream } from "../../test/bun.js/react-dom-server.bun";
38
const headers = {
49
headers: {
510
"Content-Type": "text/html",
6-
"Cache-Control": "no-transform", // set to match the Deno benchmark, which requires this for an apples to apples comparison
711
},
812
};
913

1014
const App = () => (
1115
<html>
1216
<body>
1317
<h1>Hello World</h1>
18+
<p>This is an example.</p>
1419
</body>
1520
</html>
1621
);
1722

18-
export default {
23+
const port = Number(process.env.PORT || 3001);
24+
Bun.serve({
25+
port,
1926
async fetch(req) {
20-
return new Response(await renderToReadableStream(<App />),headers);
27+
return new Response(await renderToReadableStream(<App />));
2128
},
22-
};
29+
});
30+
31+
console.log(`Server running on\n http://localhost:${port}`);
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* This source code is licensed under the MIT license found in the
88
* LICENSE file in the root directory of this source tree.
99
*/
10-
const escapeHTML = Bun.escapeHTML;
1110
var aa = require("react");
1211
function k(a) {
1312
for (
@@ -200,8 +199,7 @@ Object.keys(z).forEach(function (a) {
200199
});
201200
var ma = /["'&<>]/;
202201
function A(a) {
203-
if ("boolean" === typeof a || "number" === typeof a) return "" + a;
204-
return escapeHTML(a);
202+
return Bun.escapeHTML(a);
205203
}
206204
var na = /([A-Z])/g,
207205
oa = /^ms-/,

‎test/bun.js/react-dom.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { heapStats } from "bun:jsc";
1010
import { describe, expect, it } from "bun:test";
1111
import { renderToReadableStream as renderToReadableStreamBrowser } from "react-dom/server.browser";
1212
import { gc } from "./gc";
13-
import { renderToReadableStream as renderToReadableStreamBun } from "./reactdom-bun";
13+
import { renderToReadableStream as renderToReadableStreamBun } from "./react-dom-server.bun";
1414
import React from "react";
1515

1616
Object.defineProperty(renderToReadableStreamBrowser, "name", {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /