Pre rendering very slow and memory expensive
Reproduction
Please try building this repo
Steps to reproduce
I am building with pre-render about 1000 pages.
preact build --prerenderUrls ./prerender.js
Expected Behavior
I expect 1K pages rendering to take significantly less time and less memory.
Actual Behavior
When I try to build on a 2GB memory container, it fails with Out of Memory Error (Exit Status 137). It takes about 1 hr on 4GB machine with 4 vCPUs to build.
As it seems from the building process, preact build all of the files in memory first and then emits them, instead of emitting one by one and clearing the memory in process. This probably leads to such high memory usage.
On similar pre-rendering frameworks like react-static and Gatsby it takes about 5 min each for the same job.
I love Preact but it seems I won't be able to scale the pre-rendering for my site with it.
opened an rfc https://github.com/preactjs/preact-cli/issues/1482 regarding this
Unfortunately the experimental renderer never did make it in, but if someone still needs fast prerender.js script:
https://github.com/preactjs/preact-cli/issues/1684#issuecomment-1094349753