dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
3.91k stars 102 forks source link

SSG: partial builds #689

Closed pmelab closed 2 weeks ago

pmelab commented 2 weeks ago

Introduces a --partial flag that will skip rendering of already existing static RSC and HTML files.

Use case

Content updates of larger static sites should not re-render every page.

Notes

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview May 4, 2024 5:59am
codesandbox-ci[bot] commented 2 weeks ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

dai-shi commented 2 weeks ago
  • Consciously avoids dealing with deleting files (cache invalidation). I think this can be solved much better with userland domain knowledge.

I see, so invalidation will be done outside waku build.

  • Bundle builds should probably be skipped as well, but are too tangled at this point. At least they don't scale with the amount of static pages.

That was my concern. Felt this was suboptimal, but if it helps, it's fine. We probably need docs. Maybe after getting some feedback.

pmelab commented 2 weeks ago
  • Consciously avoids dealing with deleting files (cache invalidation). I think this can be solved much better with userland domain knowledge.

I see, so invalidation will be done outside waku build.

Yes, I heard that cache invalidation is a hard problem. I thought long about this, but if Waku should know what to clear, we inevitably go down the data-store route. Right now it is possible to implement a fetcher that collects calls during a render and associates them with the currently rendered path. That should be enough for a 3rd party implementation. I intend to do this with our Drupal GraphQL queries.

One thing that came into my mind is a waku experimental-clear [path] command that simply makes sure all the correct files (html + rsc) are deleted. But the value is not tremendous. What do you think?

dai-shi commented 2 weeks ago

One thing that came into my mind is a waku experimental-clear [path] command that simply makes sure all the correct files (html + rsc) are deleted. But the value is not tremendous. What do you think?

Not sure I get it. Do you mean deleting rsc and html files that are outdated?

pmelab commented 2 weeks ago

One thing that came into my mind is a waku experimental-clear [path] command that simply makes sure all the correct files (html + rsc) are deleted. But the value is not tremendous. What do you think?

Not sure I get it. Do you mean deleting rsc and html files that are outdated?

Yes. The system invoking the command has to know which paths are outdated, but waku knows which files belong to that path.

waku experimental-clear /my/page runs effectively rm dist/public/my/page/index.html && rm dist/public/RSC/my/page.txt

dai-shi commented 2 weeks ago

I see [path] is a path of URL.

That would be only possible if it has the knowledge of waku/router which is technically outside waku core.

pmelab commented 2 weeks ago

I see [path] is a path of URL.

That would be only possible if it has the knowledge of waku/router which is technically outside waku core.

Let's not open pandora's box to save approximately 14 seconds in 3rd party tools. If the dist directory layout changes, they will have to adapt anyway.

dai-shi commented 2 weeks ago

I'm not sure if I get your point, or if you get my point. Some examples in Waku repository doesn't use waku/router. It's already the case that we don't know about the dist structure. So, what you are suggesting would be --experimental-router-clear.

What's 14 seconds?

pmelab commented 2 weeks ago

I'm not sure if I get your point, or if you get my point. Some examples in Waku repository doesn't use waku/router. It's already the case that we don't know about the dist structure. So, what you are suggesting would be --experimental-router-clear.

What's 14 seconds?

Sorry. By that I meant that somebody implementing a invalidation mechanism would have to make the script delete two files instead of calling one command. Which is not a huge difference. And its not worth compromising the the separation between waku/lib and waku/router for that.

pmelab commented 2 weeks ago

fix: build breaks without that file (?)

I'm not sure. It happened after the merge of main and https://github.com/dai-shi/waku/pull/689/commits/920a4670bd560b50431c83fcfc7abea2d583ed9c mysteriously fixed it.