ProjectEvergreen / greenwood

Greenwood is your full-stack workbench for the web, focused on supporting modern web standards and development to help you create your next project.
https://www.greenwoodjs.io
MIT License
94 stars 9 forks source link

feature/issue 1197 Lit v3 upgrade and SSR fixes and enhancements #1201

Closed thescientist13 closed 3 months ago

thescientist13 commented 5 months ago

Related Issue

resolves #1197

Depends on the following PRs being merged first

  1. [x] #1206
  2. [x] https://github.com/ProjectEvergreen/wcc/pull/143
  3. [x] https://github.com/ProjectEvergreen/wcc/pull/141

See demo repo - https://github.com/thescientist13/greenwood-lit-ssr/pull/9

Summary of Changes

  1. Upgrade docs / Lit renderer plugin to v3
  2. Add custom exportConditions for SSR pages and API routes to now include node (like used in Lit's SSR implementation)
  3. Found some areas where we missing were HTML intercepting and optimizing during SSR pages bundling
  4. Removed need for Lit polyfill-support in the CLI (see #728)
  5. Update Lit Renderer plugin README for new usage (getBody API)
  6. Upgrade WCC to version 0.12.0

TODO

  1. [x] Implement basic hydration support for client script - https://lit.dev/docs/ssr/client-usage/#loading-@lit-labsssr-clientlit-element-hydrate-support.js
    • should it be conditional?
  2. [x] Will want to track full data hydration support as part of #880 and #1177
    • export const hydration = true
    • data loader will be needed? - export const function loader() => { /* ... */ }
  3. [x] Find a solution around the customElements.define issue - https://github.com/ProjectEvergreen/greenwood/pull/1206
  4. [x] Needs to handle some downstream dependency ESM patches for WCC
  5. [x] Update Lit Renderer Package README
    • getBody limitation for SSR pages
  6. [x] looks like we don't need to enable preferBuiltins for Lit in our Rollup config anymore?
  7. [x] WCC version 0.12.0 and delete patches/ + postinstall - https://github.com/ProjectEvergreen/wcc/releases/tag/0.12.0
  8. [x] Default Hydration Settings for plugins and docs
    • WCC - false
    • Lit - true
  9. [x] clean up TODOs / comments / cross-tracking

Thoughts / Questions

  1. [x] check if exportConditions are still needed after #1087
  2. [x] plugins have to manage their own type="module-shim" 🤔
    • yes for now, but I think we can probably plan to get this into the release #1114
  3. [x] Lit - should track as part of v0.30.0 release blog post
  4. [x] How come the Lit card re-renders on client side in our demo repo? - ah, most likely due to not populating the data on the client side - https://github.com/lit/lit/issues/3651
    • need the polyfill?
    • chrome doesn't already support it? (is this a shadowrootmode thing?)