Rename reactdom-bun -> react-dom-server.bun

This commit is contained in:
Jarred Sumner
2022-08-21 01:00:27 -07:00
parent a8fa61ed68
commit c4580ee2ca
3 changed files with 16 additions and 9 deletions

View File

@@ -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}`);

View File

@@ -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-/,

View File

@@ -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", {