diff options
author | 2021-06-29 17:47:58 -0700 | |
---|---|---|
committer | 2021-06-29 17:47:58 -0700 | |
commit | 3f197d1ce0c197864ad4c7c7b8238af4370275b4 (patch) | |
tree | 7d76dcc182e80c5b67db1568e769977229649980 /demos/css-stress-test | |
parent | 26745bb5f300481fc242c8e81de6f252f698c863 (diff) | |
download | bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.tar.gz bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.tar.zst bun-3f197d1ce0c197864ad4c7c7b8238af4370275b4.zip |
Fix crash, fix detecting node_modules, fix undefined not being simplified
Diffstat (limited to 'demos/css-stress-test')
-rw-r--r-- | demos/css-stress-test/react-inject.js | 1 | ||||
-rw-r--r-- | demos/css-stress-test/src/index.tsx | 27 | ||||
-rw-r--r-- | demos/css-stress-test/src/main.tsx | 2 |
3 files changed, 21 insertions, 9 deletions
diff --git a/demos/css-stress-test/react-inject.js b/demos/css-stress-test/react-inject.js new file mode 100644 index 000000000..199dbaa80 --- /dev/null +++ b/demos/css-stress-test/react-inject.js @@ -0,0 +1 @@ +export { default as React } from "react"; diff --git a/demos/css-stress-test/src/index.tsx b/demos/css-stress-test/src/index.tsx index 3db53a67f..267691467 100644 --- a/demos/css-stress-test/src/index.tsx +++ b/demos/css-stress-test/src/index.tsx @@ -1,20 +1,33 @@ -import ReactDOM from "react-dom"; -import React from "react"; +import ReactDOMServer from "react-dom/server.browser"; + import { Main } from "./main"; import classNames from "classnames"; - const Base = ({}) => { - const name = decodeURIComponent(location.search.substring(1)); + const name = + typeof location !== "undefined" + ? decodeURIComponent(location.search.substring(1)) + : null; return <Main productName={name || "Bundler"} />; }; function startReact() { + const ReactDOM = require("react-dom"); ReactDOM.render(<Base />, document.querySelector("#reactroot")); } -globalThis.addEventListener("DOMContentLoaded", () => { +function ssr() { + console.log(ReactDOMServer.renderToString(<Base />)); +} + +if (typeof window !== "undefined") { + console.log("HERE!!"); + globalThis.addEventListener("DOMContentLoaded", () => { + startReact(); + }); + startReact(); -}); -startReact(); +} else { + ssr(); +} export { Base }; diff --git a/demos/css-stress-test/src/main.tsx b/demos/css-stress-test/src/main.tsx index 1a9948fe8..c95d0f0eb 100644 --- a/demos/css-stress-test/src/main.tsx +++ b/demos/css-stress-test/src/main.tsx @@ -1,5 +1,3 @@ -import React from "react"; - export const Main = ({ productName }) => { return ( <> |