Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ml-in-barcelona/server-reason-react…
Browse files Browse the repository at this point in the history
… into fix-render-to-lwt-stream

* 'main' of github.com:ml-in-barcelona/server-reason-react:
  Run extract-client-components as an esbuild plugin (#199)
  • Loading branch information
davesnx committed Jan 21, 2025
2 parents 7c15447 + 346fd3e commit 7e21588
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
37 changes: 7 additions & 30 deletions arch/server/render-html-to-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const sleep = (seconds) =>
new Promise((res) => setTimeout(res, seconds * 1000));

const DefferedComponent = async ({ by, children }) => {
return sleep(by).then(() => {
return (
await sleep(by);
return (
<div>
Sleep {by}s, {children}
</div>
);
});
};

const decoder = new TextDecoder();
Expand Down Expand Up @@ -40,36 +39,14 @@ const debug = (readableStream) => {
</React.Suspense>
); */

/* const UsePromise = ({promise}) => {
let data = React.use(promise);
return <div>{data}</div>;
};
const App = () => {
let promise = new Promise((resolve) => setTimeout(() => resolve("lol"), 1000));
return (
<div>
<UsePromise promise={promise} />
</div>
);
}; */


/* const AlwaysThrow = () => {
throw new Error("always throwing");
};
const App = () => (
<React.Suspense fallback="Fallback 1">
<AlwaysThrow/>
</React.Suspense>
); */

/* const App = () => (
<DefferedComponent by={1}>"lol"</DefferedComponent>
<div>
<React.Suspense fallback="Fallback 1">
<DefferedComponent by={0}>"lol"</DefferedComponent>
</React.Suspense>
</div>
); */


const AlwaysThrow = () => {
throw new Error("always throwing");
};
Expand Down
6 changes: 3 additions & 3 deletions demo/client/dune
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
(package server-reason-react)
(alias_rec melange)
(:script build.mjs)
(:input "app/demo/client/index.js")
(:input app/demo/client/index.js)
(source_tree node_modules)
(file package.json)
(source_tree %{project_root}/packages/extract-client-components))
(source_tree ../../packages/extract-client-components))
(target index.js)
(action
(progn
Expand Down Expand Up @@ -58,7 +58,7 @@
(:script build.mjs)
(file package.json)
(source_tree node_modules)
(source_tree %{project_root}/packages/extract-client-components))
(source_tree ../../packages/extract-client-components))
(action
(progn
(run node %{script} %{input} app/demo/client/ --extract=true))))

0 comments on commit 7e21588

Please sign in to comment.