Commit 72fcf0d
authored
[SSR/Core] Add @lit-labs/ssr-dom-shim package (#3522)
- Adds a new `@lit-labs/ssr-dom-shim` package which exports `Element`, `HTMLElement`, `CustomElementRegistry`, and a default global `customElements` (but does not register any of them as globals).
- Updates `@lit/reactive-element/reactive-element.js` to import from this package in its node build, instead of providing inline no-op versions. This means the parts of the DOM shim required for most Lit components will always be loaded in Node, so that users don't need to think about loading the DOM shim at all anymore.
- When using this new automatic shimming by importing `reactive-element` from Node, only a single global will now be defined: `customElements`. So in particular, `window` will not be defined, solving many issues we encountered with libraries sniffing for `window` to switch between node vs browser modes.
- `ModuleLoader` now provides a default VM global context object which provides basic globals that are available in both Node and browsers. A context object can also be directly created with a new `makeDefaultContextObject` function.
- Updates `lit-html/experimental-hydrate.js` to not depend on `btoa` when running in Node, instead using Node's built-in `Buffer`.
- Updates the existing `@lit-labs/ssr/lib/dom-shim.js` module to import `HTMLElement` and `customElements` from the new package, so that the same base class and registry are used when the full DOM shim is loaded.
- Makes registering a duplicate element in the DOM shim throw an exception.
- Misc minor improvements to the DOM shim code, including moving APIs from `HTMLElement` to `Element`, which is the correct interface for them.
- Updates to the following packages to remove usage of the global DOM shim in code/tests/READMEs:
- `@lit-labs/testing`
- `@lit-labs/eleventy-plugin-lit`
- `@lit-labs/ssr`
- `@lit/localize-tools`
See also lit/lit.dev#1026 which updates the lit.dev docs for these changes.
Fixes #35231 parent d1f9d14 commit 72fcf0d
41 files changed
Lines changed: 1256 additions & 586 deletions
File tree
- .changeset
- packages
- labs
- eleventy-plugin-lit/src/worker
- gen-utils/src/test
- ssr-dom-shim
- src
- ssr
- src
- demo
- global
- vm-modules
- lib
- test
- integration
- client
- server
- tests
- lib
- testing/src
- lib
- test
- lit-html/src
- localize-tools
- src/tests
- reactive-element
- src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
265 | 267 | | |
266 | 268 | | |
267 | 269 | | |
| |||
0 commit comments