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

[SSR/Core] Add @lit-labs/ssr-dom-shim package #3522

Merged
merged 51 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7bbec6b
Add new @lit-labs/ssr-dom-shim package skeleton
aomarks Dec 14, 2022
2951f7c
Copy dom-shim.ts to new package index.ts
aomarks Dec 14, 2022
43e0f81
Add package.json files config
aomarks Dec 14, 2022
ad9bffb
Remove un-needed stuff from new dom shim
aomarks Dec 14, 2022
95620d9
Add new exports
aomarks Dec 14, 2022
11095a4
Fix typing issue
aomarks Dec 14, 2022
44c7238
Update old DOM shim to import from new DOM shim
aomarks Dec 14, 2022
e3ab939
Install @rollup/plugin-inject
aomarks Dec 14, 2022
766bea6
Import @lit-labs/ssr-dom-shim directly from reactive-element Node build
aomarks Dec 14, 2022
dc3d0fd
Still create a new CustomElementRegistry when calling the getWindow f…
aomarks Dec 14, 2022
7cf82c7
Fall back to global HTMLElement as the base class for ReactiveElement…
aomarks Dec 14, 2022
7a0b465
Add types exports, and inject dom shim into node+dev build too
aomarks Dec 15, 2022
b7dc1b9
Reset version of new package to 0.0.1 so that changeset will bump it …
aomarks Dec 15, 2022
6562ee6
Add changeset
aomarks Dec 15, 2022
7dc5caa
Add wireit builds for new package and fix package JSON
aomarks Dec 15, 2022
8c67606
Make it so we still simply `extend HTMLElement` from TypeScript's per…
aomarks Dec 15, 2022
3038cb5
Temporarily skip test that will fail until we first publish @lit-labs…
aomarks Dec 15, 2022
74b010d
Export Element (empty class) from @lit-labs/ssr-dom-shim
aomarks Dec 15, 2022
7d48c8f
Automatically shim btoa for Node in lit/experimental-hydrate
aomarks Jan 4, 2023
5a0b90d
Update Lit SSR unit tests to show that no global shimming is now requ…
aomarks Jan 4, 2023
fc17fd7
Update changeset for new lit-html/experimental-hydrate.js shim
aomarks Jan 4, 2023
0627c1c
Merge branch 'main' into dom-shim-package
aomarks Jan 4, 2023
8e4a345
Fix module resolution in SSR demos
aomarks Jan 4, 2023
59e57e9
Remove global DOM shim from SSR demos
aomarks Jan 5, 2023
82923e8
Update dom-shim exports to be typed as the real globals
aomarks Jan 5, 2023
b6a621d
Update SSR integration tests to cover global and vm mode, with and wi…
aomarks Jan 5, 2023
a5a0d44
Add a default context object for ModuleLoader
aomarks Jan 5, 2023
2e2ee7a
Fix buffer import typo
aomarks Jan 6, 2023
234c4c7
Remove unnecessary ignores
aomarks Jan 6, 2023
bc57977
Minor tweaks to dom shim
aomarks Jan 6, 2023
e1d7931
Make DOM shim throw on duplicate registration
aomarks Jan 6, 2023
db78c7d
Fix tests to account for duplicate registration exception
aomarks Jan 6, 2023
c798159
Move APIs from HTMLElement to Element, which is where they are really…
aomarks Jan 6, 2023
abe8d0f
Add README for new ssr-dom-shim package
aomarks Jan 6, 2023
4f1b45c
Don't load global DOM shim from eleventy ssr plugin
aomarks Jan 6, 2023
3942cd7
Update localize SSR test to not use global DOM shim
aomarks Jan 6, 2023
e3b5e1d
Don't load the global DOM shim from @lit-labs/testing
aomarks Jan 6, 2023
3eec833
Update Lit SSR readme to not recommend global dom shim
aomarks Jan 6, 2023
73f4329
Fix some typos
aomarks Jan 6, 2023
b35b66b
Force SSR browser tests to run with CONCURRENT_BROWSERS=1
aomarks Jan 6, 2023
d4a9ca9
Update packages/localize-tools/src/tests/ssr.unit.test.ts
aomarks Jan 6, 2023
d612258
Update packages/labs/testing/src/lib/worker.ts
aomarks Jan 6, 2023
2779e2a
Update packages/localize-tools/CHANGELOG.md
aomarks Jan 6, 2023
2e0192f
Update packages/labs/eleventy-plugin-lit/src/worker/worker.ts
aomarks Jan 6, 2023
0e376b3
Might as well release 1.0.0 of eleventy plugin
aomarks Jan 6, 2023
43fe469
Add missing 'node'
aomarks Jan 6, 2023
a851fcd
Add missing -- to experimental-vm-modules flag
aomarks Jan 6, 2023
22239f5
Add custom element registry reset hack to SSR test server
aomarks Jan 6, 2023
14b0d94
Add comment about observedAttributes side-effect
aomarks Jan 6, 2023
50182cf
A simpler way to avoid duplicate registrations!
aomarks Jan 6, 2023
4f01ca2
Do register elements every time in vm mode
aomarks Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-cooks-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/eleventy-plugin-lit': major
---

The Lit SSR global DOM shim is no longer automatically loaded when rendering Lit components from Eleventy. When paired with the latest version of Lit, the global DOM shim is no longer typically required, because Lit now automatically imports shimmed versions of needed APIs.
5 changes: 5 additions & 0 deletions .changeset/fair-spiders-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/ssr': major
---

ModuleLoader now provides a default VM global context object which provides basic globals that are available in both Node and browsers.
5 changes: 5 additions & 0 deletions .changeset/fast-insects-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/ssr': major
---

The SSR dom shim will now throw if a custom element is redefined.
12 changes: 12 additions & 0 deletions .changeset/healthy-pants-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@lit-labs/testing': minor
---

@lit-labs/testing no longer automatically loads the Lit SSR global DOM shim
when performing SSR, instead relying on newer versions of Lit which automatically
load necessary shims with minimal global pollution.

This may cause new or different test failures, because APIs such as `document`
will no longer be available on the server by default. Use `isServer` from the
`lit` package to guard against calling such APIs during SSR (see
https://lit.dev/docs/ssr/authoring/#browser-only-code for more information).
15 changes: 15 additions & 0 deletions .changeset/olive-shoes-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@lit-labs/ssr-dom-shim': major
'@lit-labs/ssr': minor
'@lit/reactive-element': minor
'lit-html': minor
'lit': minor
---

When running in Node, Lit now automatically includes minimal DOM shims which are
sufficient for most SSR (Server Side Rendering) use-cases, removing the need to
import the global DOM shim from `@lit-labs/ssr`.

The new `@lit-labs/ssr-dom-shim` package has been introduced, which exports an `HTMLElement`, `CustomElementRegistry`, and default `customElements` singleton.

The existing `@lit-labs/ssr` global DOM shim can still be used, and is compatible with the new package, because `@lit-labs/ssr` imports from `@lit-labs/ssr-dom-shim`. Importing the global DOM shim adds more APIs to the global object, such as a global `HTMLElement`, `TreeWalker`, `fetch`, and other APIs. It is recommended that users try to remove usage of the `@lit-labs/ssr` DOM shim, and instead rely on the more minimal, automatic shimming that `@lit/reactive-element` now provides automatically.
5 changes: 5 additions & 0 deletions .changeset/rich-icons-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-labs/ssr': minor
---

APIs such as attachShadow, setAttribute have been moved from the HTMLElement class shim to the Element class shim, matching the structure of the real API. This should have no effect in most cases, as HTMLElement inherits from Element.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ packages/labs/ssr-client/controllers/
packages/labs/ssr-client/node_modules/
packages/labs/ssr-client/index.*

packages/labs/ssr-dom-shim/index.*

packages/labs/task/development/
packages/labs/task/test/
packages/labs/task/node_modules/
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ packages/labs/ssr-client/controllers/
packages/labs/ssr-client/node_modules/
packages/labs/ssr-client/index.*

packages/labs/ssr-dom-shim/index.*

packages/labs/task/development/
packages/labs/task/test/
packages/labs/task/node_modules/
Expand Down
Loading