Skip to content
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

introduction of server side rendering #838

Merged
merged 19 commits into from
Jan 14, 2022

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Dec 28, 2021

Related Issue

resolves #708 (extracted from #812)

Summary of Changes

  1. Introduce an ssr mode (ssr mode "conflicts" with MPA mode, see TODOs section below)
  2. Add test cases
  3. Added documentation

Opted for a Workers based approach for cache busting ESM in development

Screen Shot 2021-11-24 at 6 53 49 PM

I think what's really cool about the possibilities here is how seamless it would be to run a hybrid application, such that you can have a set of static and dynamic pages and routes that can all share the same static resources, yet still feel like one app.

src/
  pages/
    about.md
    index.html
    contact.html
  routes/
    artists.js
    artist.js
  templates/
    app.html
    page.html
    product.html
  styles/
    theme.css
    artist.css
    main.css

In this way

  • your landing / marketing "pages" can consist of static pages at build time (either as markdown or from a headless CMS)
  • that can co-locate with "routes" that can be server rendered, but still re-use the same templating system

I tried to demonstrate that here in this PR with the "Artists" page, though obviously this will not work on Netlify, but you can try it locally!

  1. Run yarn serve
  2. Load localhost:8080/artists/

TODOs

  1. ESM doesn't have the same caching mechanism features as CJS, including clearing the module cache, which means SSR routes don't reload on browser refresh.
  2. Full support for
    • getTemplate()
    • getContent()
    • getMetadata()
  3. Handle graph / frontmatter integration
  4. Handle static asset bundling for serve command
  5. Handle pre-rendering for serve command
  6. Testing
  7. Documentation
  8. Fix windows github action error
  9. Tracking / Questions / Car (all breaking changes would go into a release branch)
    1. (breaking) fluid "mode" / workspace configuration (autodetect based on pages, routes, etc) - have Greenwood auto detect project (mode) and expose client router option ("fluid" workspaces) #856
    2. (breaking) prerender: false by default and avoid puppeteer install - make prerender config option false by default #855
    3. (discussion) Fastify instead of Koa - Fastify Server and standard Request / Response #867
    4. Need more in memory driven architecture / pipelines which will become more handy as part of serverless, for things like Rollup bundling for SSR - Serverless (+ single route builds) #626 (comment)
    5. Need to have some sort of in cached bundling for SSR? Check if it exists on filesystem instead of in a Map for rollup bundling already bundled assets? - Serverless (+ single route builds) #626 (comment)
    6. why can't standard HTML just get all the data from the graph instead of all of this path finding stuff that was already done in the graph? - refactor html plugin serve to use graph to lookup files and content #854
    7. Review "meta" adjacent issues
  10. Start release branch and follow same strategy as last release branch - with carry over TODOs
    • SSR guide (using AWS, Heoruku, etc)
    • More port options
    • website updates (now that we're more than just SSG)
    • static export option for SSR routes / pre-render off
    • TypeScript support for routes (post release?)
    • nested dynamic routes, e.g. /artist/${id} (post release?)
    • Graph lifecycle + standard plugin html refactoring (nice to have, else track)
  11. Clean up demo code and merge into release branch , bring along any untracked items as new TODOs

@thescientist13 thescientist13 added RFC Proposal and changes to workflows, architecture, APIs, etc CLI SSR discussion tied to an ongoing discussion or meeting notes feature New feature or request labels Dec 28, 2021
@thescientist13 thescientist13 self-assigned this Dec 28, 2021
@thescientist13 thescientist13 added the documentation Greenwood specific docs label Jan 8, 2022
@thescientist13 thescientist13 marked this pull request as ready for review January 8, 2022 01:12
@thescientist13 thescientist13 force-pushed the feature/issue-708-server-side-rendering branch from 50cef7a to 2c0c22d Compare January 10, 2022 16:53
@thescientist13 thescientist13 force-pushed the feature/issue-708-server-side-rendering branch from 2c0c22d to 945ea56 Compare January 14, 2022 01:51
@thescientist13 thescientist13 changed the base branch from master to release/0.23.0 January 14, 2022 02:14
@thescientist13 thescientist13 merged commit 3230cda into release/0.23.0 Jan 14, 2022
@thescientist13 thescientist13 deleted the feature/issue-708-server-side-rendering branch January 14, 2022 02:15
@thescientist13 thescientist13 mentioned this pull request Jan 14, 2022
27 tasks
thescientist13 added a commit that referenced this pull request Feb 12, 2022
* initial introduction of server side rendering

* update config spec

* ESM cache busting in development with workers

* correctly establish body and template support for SSR routes

* basic metadata support

* frontmatter and graph support

* fix lint

* basic smoke test case for SSR

* fix and clean up specs

* basic smoke testing with HTML optimization for server routes

* handle pre-rendering for SSR routes

* support SSR bundling

* full frontmatter support and custom route data for SSR routes

* document server rendering

* add ssr mode to config docs

* clarify serve command in README

* ESM path to file interop for windows

* rebase fixes

* remove demo code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI discussion tied to an ongoing discussion or meeting notes documentation Greenwood specific docs feature New feature or request RFC Proposal and changes to workflows, architecture, APIs, etc SSR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce an SSR mode for Greenwood
1 participant