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

demo/restore products page and upgrade to Lit v3 #9

Closed
wants to merge 11 commits into from

Conversation

thescientist13
Copy link
Owner

@thescientist13 thescientist13 commented Nov 21, 2023

resolves #3 / #6

Changes

  1. Upgraded lit to v3 and update import for render
  2. Refactor renderToString to use new collectResult SSR API

TODO

  1. Products page has double rendering in dev
  2. All SSR fails when running serve
         ReferenceError: HTMLElement is not defined
         at file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/public/api/card.04a6f554.js:204:752
         at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
         at async Promise.all (index 0)
         at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
         at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:305:29
         at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:275:7
         at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:233:5
         at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:200:5
       
  3. Global registry conflicts when running greenwood serve, ex. load the API routes a couple times (seems fine when run on serverless) - feature/discussion 1117 Isolation Mode (v1) ProjectEvergreen/greenwood#1206
    • maybe this is why workers are good?
    Error: Failed to execute 'define' on 'CustomElementRegistry': the name "app-card" has already been used with this registry
    at CustomElementRegistry.define (file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/public/lit-element.2f782e55.js:220:23)
    at file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/public/api/card.658da880.js:11316:16
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:305:29
    at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:275:7
    at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:233:5
    at async file:///Users/owenbuckley/Workspace/github/greenwood-demo-adapter-vercel-lit/node_modules/@greenwood/cli/src/lifecycles/serve.js:200:5

Upstream Needs Tracking / Notes

ProjectEvergreen/greenwood#1197

Greenwood CLI

  1. Looks like are we missing HTML intercepting and optimizing during SSR pages bundling
  2. prune hydration data / page data from compilation
  3. plugins have to manage their own type="module-shim"
  4. Adjacent needs - Blocking issues

Lit Renderer

  1. Upgrade lit renderer plugin to lit v3 SSR
  2. "Full" Hydration support
  3. Document Caveats in Lit Renderer Plugin README
    • @lit-labs/ssr-client as a first party dependency
    • hydration script is needed
    • have to use getBody / getPage API
    • hydration will be needed? - export const hydration = true
    • data loader will be needed? - export const function loader() => { /* ... */ }

Thoughts / Questions

  1. How come the Lit card re-renders on client side? (make a repro repo)
    • need the polyfill?
    • chrome doesn't already support it?
  2. After this, could we suggest adding ourselves to the list of tools here (or maybe after the website redesign)? - https://lit.dev/docs/ssr/overview/

@thescientist13 thescientist13 added enhancement New feature or request needs upstream labels Nov 21, 2023
Copy link

vercel bot commented Nov 21, 2023

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

Name Status Preview Comments Updated (UTC)
greenwood-demo-adapter-vercel-lit ❌ Failed (Inspect) Feb 27, 2024 2:47am
greenwood-lit-ssr ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 2:47am

@thescientist13 thescientist13 changed the title upgrade to lit v3 enhancement/issue 6 upgrade to lit v3 Nov 21, 2023
@thescientist13 thescientist13 self-assigned this Nov 21, 2023
@thescientist13
Copy link
Owner Author

thescientist13 commented Nov 21, 2023

So interestingly, if I add the hydration support script from Lit, the double products page render goes away but....

<script type="module" src="/node_modules/@lit-labs/ssr-client/lit-element-hydrate-support.js"></script>

Screenshot 2023-11-21 at 9 23 04 AM

The interactivity breaks lolsad, The constructor is definitely running based on the logging, but not the render function? 🤔

@thescientist13 thescientist13 changed the title enhancement/issue 6 upgrade to lit v3 enhancement/restore products page and upgrade to Lit v3 Dec 1, 2023
@thescientist13 thescientist13 changed the title enhancement/restore products page and upgrade to Lit v3 demo/restore products page and upgrade to Lit v3 Jan 27, 2024
@thescientist13 thescientist13 removed the enhancement New feature or request label Jan 27, 2024
@thescientist13
Copy link
Owner Author

Will keep this as a reference and will drive through the polished through #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

restore products page (support async work in Lit SSR page routes)
1 participant