-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prerender Part 1 & 2: Render landing/marketing/static pages + Private page whileLoading #1641
Conversation
…ender-p1 * 'main' of github.com:redwoodjs/redwood: v0.23.0 GH Action PR Comment: Formatting add learn.rwjs.com repo to contributors (redwoodjs#1634) update PR Package Action formatting Updated All-Contributors Data (redwoodjs#1621) sync yarn.lock (redwoodjs#1632) Resolve promises in the console (redwoodjs#1619) Replace prisma deprecated fineOne() -> findUnique() (redwoodjs#1629)
Closes #217 |
6cd517c
to
adf9644
Compare
This is awesome @dac09! Everything sounds good to me. My initial thought when we talked about getting this working was the prop name |
Thanks @cannikin! Yeah it does hydrate after the page loads, so more like a "partial render", that the browser then enhances to become more dynamic. Still quite a bit to do, but it's taking shape! |
…dwood into feature/prerender-p1 * 'show/circular-dep-prerender' of github.com:redwoodjs/redwood: Use global instead of process.env. Update yarn.lock. Remove babel deps and organize devDeps. Fix references and deps. Add prerender to TS references. Interally use env-vars instead of helper functions to determine prerendering. Commit changes to show peterp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nicely done @dac09 !
One more tweak needed :), template variables don't match. then I'll merge |
…rib-workspaces * 'main' of github.com:redwoodjs/redwood: Prerender Part 1 & 2: Render landing/marketing/static pages + Private page whileLoading (redwoodjs#1641)
How do you use this?
For pages you'd like to prerender add the prerender prop
In your redwood.toml, add
[web] port = 8910 apiProxyPath = "/.netlify/functions" + experimentalPrerender = true
Now when you build your redwood app, it will add an extra build step to prerender your pages.
You can also manually trigger prerendering with
If you have an existing app, some changes to your index.js and index.html file (see create-redwood-app template)
So far looking ok on:
bypass App.js (to limit how much we need to change), and only render pagesuseIsBrowser
to detect if its in running in the browser, this will become very important (if you've tried some SSG stuff on next/express you probably recognise why). I'm not the biggest fan of this solution though<BrowserOnly>
to bypass prerenderingTodo
yarn rw build web
it doesn't show errors if it fails to prerender. This isn't that bad, because your app will still run. This is limitation of how we're doing Listr tasks I guess?Need help / still in progress:
- renderingwhileLoading
for Private routesAfter a lot of hacking around with babel and tsmorph (thanks @aldonline) - modifying the router and the routes-autoloader plugin was the correct approach
getting babel-plugin-redwood-directory-import to play niceThanks @peterp
importing TypeScript pages in the router (is this a general problem, or an issue I just created?)unrelated issue, solved elsewhere
should we form a list of routes inside the prerender context separately instead of rendering<Routes/>
? This feels like a workaround to me, just to makerouter.routes.homepage()
work for example.Not relevant anymore, as we're rerendering the whole App
remove window from the rest of the codebase, so I can remove the window shim. While the shim works great with just redwood, it can start to show issues on external libraries because they think its running in the browserExecution flow is clear of window
Couple other things to note:
Out of scope for this PR, but important:
[ ] the way svgs are imported can be an issue[ ] image imports in general are an issue, because the currently build workflow is using webpack’s url-loader, we’d need to transition to something like https://github.com/ahalimkara/babel-plugin-import-static-files or https://github.com/cyrilwanner/react-optimized-image and remove the webpack plugin for it to work on both serverside and client side. This gives us other benefits, but requires changing how we recommend using images in redwood^^ Covered in Feature/prerender image support #1721