From b9d7ebaac34025641ab8dda470de52fef761b32a Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Sat, 30 May 2026 19:10:45 -0400 Subject: [PATCH] feature(plugins): #1646 support lit ssr default export for pages and layouts --- packages/plugin-renderer-lit/README.md | 10 +- packages/plugin-renderer-lit/package.json | 8 +- .../src/execute-route-module.js | 97 ++++++- .../cases/serve.default/serve.default.spec.js | 249 +++++++++++++++--- .../cases/serve.default/src/layouts/album.js | 36 +++ .../serve.default/src/pages/album/foo.html | 9 + .../serve.default/src/pages/artist/[name].js | 16 ++ .../serve.default/src/pages/product/[id].js | 18 ++ .../cases/serve.default/src/pages/products.js | 32 +++ yarn.lock | 22 +- 10 files changed, 435 insertions(+), 62 deletions(-) create mode 100644 packages/plugin-renderer-lit/test/cases/serve.default/src/layouts/album.js create mode 100644 packages/plugin-renderer-lit/test/cases/serve.default/src/pages/album/foo.html create mode 100644 packages/plugin-renderer-lit/test/cases/serve.default/src/pages/artist/[name].js create mode 100644 packages/plugin-renderer-lit/test/cases/serve.default/src/pages/product/[id].js create mode 100644 packages/plugin-renderer-lit/test/cases/serve.default/src/pages/products.js diff --git a/packages/plugin-renderer-lit/README.md b/packages/plugin-renderer-lit/README.md index 1c4c1d33d..ed268be53 100644 --- a/packages/plugin-renderer-lit/README.md +++ b/packages/plugin-renderer-lit/README.md @@ -74,13 +74,15 @@ import type { LitRendererPlugin } from '@greenwood/plugin-renderer-lit'; ## Caveats 1. Lit SSR [does not support native `HTMLElement`](https://github.com/lit/lit/discussions/2092) which means **_you will need to use `LitElement` as your base class in all instances where you are pre-rendering or using SSR_**. -1. Be aware of the known documented [caveats](https://lit.dev/docs/ssr/overview/#library-status) as called out in the Lit SSR docs, such as: - - Lit SSR [**only** renders into declarative shadow roots](https://github.com/lit/lit/issues/3080#issuecomment-1165158794), so you will have to keep browser support and polyfill usage in mind. - - At this time, `LitElement` does not support `async` work (e.g. for `connectedCallback`). You can follow along with this issue [in the Lit repo](https://github.com/lit/lit/issues/2469). -1. Lit only supports templates on the server side for HTML generated content, thus Greenwood's `getBody` API must be used. We would love for [server only components](https://github.com/lit/lit/issues/2469#issuecomment-1759583861) to be a thing though! +1. Be aware of the known [caveats](https://lit.dev/docs/ssr/overview/#library-status) as called out in the Lit SSR docs, such as: + - Lit SSR [**only** renders into declarative shadow roots](https://github.com/lit/lit/issues/3080#issuecomment-1165158794), so you will have to keep browser support (and polyfill usage) in mind. + - At this time, `LitElement` does not support `async` work (e.g. for `connectedCallback`). You can follow along with [this issue](https://github.com/lit/lit/issues/2469) and [this issue](https://github.com/lit/lit/issues/4866) from the Lit repo. +1. For constructor props support, you will have to [map attributes to properties](https://greenwoodjs.dev/docs/plugins/lit-ssr/#usage) 1. Lit does not support [`CSSStyleSheet` (aka CSS Modules) in their SSR DOM shim](https://github.com/lit/lit/issues/4862). As an alternative, you may consider using Greenwood's [**Raw adapter**](https://greenwoodjs.dev/docs/plugins/raw/) to inline CSS in `