From 379f08ff47ee226fe8e478fe4a3ee275a09828e8 Mon Sep 17 00:00:00 2001 From: Thomas Allmer Date: Sat, 13 Aug 2022 18:24:16 +0200 Subject: [PATCH] feat(engine): remove global dom shim workaround --- .changeset/funny-seals-run.md | 6 +++ examples/01-hydration-starter/package.json | 2 +- examples/02-blog-starter/package.json | 2 +- examples/03-minimal-starter/package.json | 2 +- .../frontend/package.json | 2 +- examples/50-landing-theme-spark/package.json | 2 +- examples/51-docs-theme-launch/package.json | 2 +- packages/components/package.json | 2 +- packages/engine/package.json | 6 +-- packages/engine/src/formats/markdown.js | 4 -- packages/engine/src/index.js | 4 -- packages/engine/src/worker/importWorker.js | 4 -- packages/engine/src/worker/renderWorker.js | 4 -- .../test-node/04a-renderJoiningGroup.test.js | 1 - packages/launch/package.json | 2 +- packages/mdjs-preview/package.json | 2 +- packages/mdjs-story/package.json | 2 +- presets/spark/package.json | 2 +- yarn.lock | 42 +++++++++---------- 19 files changed, 41 insertions(+), 52 deletions(-) create mode 100644 .changeset/funny-seals-run.md diff --git a/.changeset/funny-seals-run.md b/.changeset/funny-seals-run.md new file mode 100644 index 00000000..dcae1d3a --- /dev/null +++ b/.changeset/funny-seals-run.md @@ -0,0 +1,6 @@ +--- +'@rocket/engine': patch +--- + +Remove the lit workaround to globally load the `global-dom-shim` in the "main thread". +Which means only the worker that does the actual SSR rendering will load it. diff --git a/examples/01-hydration-starter/package.json b/examples/01-hydration-starter/package.json index 24b75ace..c0f5c7b7 100644 --- a/examples/01-hydration-starter/package.json +++ b/examples/01-hydration-starter/package.json @@ -14,7 +14,7 @@ "@rocket/cli": "^0.20.0", "@rocket/engine": "^0.2.0", "@webcomponents/template-shadowroot": "^0.1.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Hydration Starter", "imports": { diff --git a/examples/02-blog-starter/package.json b/examples/02-blog-starter/package.json index a5275a94..cadfe7e3 100644 --- a/examples/02-blog-starter/package.json +++ b/examples/02-blog-starter/package.json @@ -18,7 +18,7 @@ "devDependencies": { "@rocket/cli": "^0.20.0", "@rocket/engine": "^0.2.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Blog Starter" } diff --git a/examples/03-minimal-starter/package.json b/examples/03-minimal-starter/package.json index 92f7cad3..03c9b2ab 100644 --- a/examples/03-minimal-starter/package.json +++ b/examples/03-minimal-starter/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@rocket/cli": "^0.20.0", "@rocket/engine": "^0.2.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Minimal Starter" } diff --git a/examples/04-sanity-minimal-starter/frontend/package.json b/examples/04-sanity-minimal-starter/frontend/package.json index 0d7a3322..bcfc1de8 100644 --- a/examples/04-sanity-minimal-starter/frontend/package.json +++ b/examples/04-sanity-minimal-starter/frontend/package.json @@ -18,7 +18,7 @@ "@sanity/client": "^3.1.0", "@sanity/image-url": "^1.0.1", "dotenv": "^16.0.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Sanity Minimal Starter" } diff --git a/examples/50-landing-theme-spark/package.json b/examples/50-landing-theme-spark/package.json index e8e9b413..acb35e59 100644 --- a/examples/50-landing-theme-spark/package.json +++ b/examples/50-landing-theme-spark/package.json @@ -15,7 +15,7 @@ "@rocket/components": "^0.2.0", "@rocket/engine": "^0.2.0", "@rocket/spark": "^0.2.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Landing Page (@rocket/spark Theme)", "imports": { diff --git a/examples/51-docs-theme-launch/package.json b/examples/51-docs-theme-launch/package.json index bb492805..04b1d6bf 100644 --- a/examples/51-docs-theme-launch/package.json +++ b/examples/51-docs-theme-launch/package.json @@ -15,7 +15,7 @@ "@rocket/engine": "^0.2.0", "@rocket/launch": "^0.21.0", "@rocket/search": "^0.7.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "@rocket/template-name": "Documentation Website (@rocket/launch Theme)", "imports": { diff --git a/packages/components/package.json b/packages/components/package.json index 27792e4a..c8692206 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -43,7 +43,7 @@ "dependencies": { "@webcomponents/template-shadowroot": "^0.1.0", "fontawesome-free": "^1.0.4", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "devDependencies": {}, "types": "./dist-types/exports/index.d.ts", diff --git a/packages/engine/package.json b/packages/engine/package.json index 4b99840f..e9bc6c1d 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -35,7 +35,7 @@ "scripts": { "debug": "DEBUG=engine:rendering yarn test", "debug:integration": "PWDEBUG=1 yarn test:integration", - "test": "mocha --require ../../scripts/testMochaGlobalHooks.js --timeout 5000 test-node/**/*.test.js test-node/*.test.js", + "test": "mocha --require ../../scripts/testMochaGlobalHooks.js --timeout 8000 test-node/**/*.test.js test-node/*.test.js", "test:integration": "playwright test test-node/*.spec.js", "test:watch": "onchange 'src/**/*.js' 'test-node/**/*.js' -- npm test", "types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/" @@ -47,12 +47,12 @@ ], "dependencies": { "@d4kmor/tree-model": "^0.1.3", - "@lit-labs/ssr": "^2.0.4", + "@lit-labs/ssr": "^2.2.3", "@mdjs/core": "^0.20.0", "@parcel/watcher": "^2.0.5", "@web/dev-server": "^0.1.4", "es-module-lexer": "^0.10.5", - "lit": "^2.2.5", + "lit": "^2.3.0", "plugins-manager": "^0.3.0", "sax-wasm": "^2.1.3", "unist-util-visit": "^4.1.0" diff --git a/packages/engine/src/formats/markdown.js b/packages/engine/src/formats/markdown.js index 421365f6..603b2ddf 100644 --- a/packages/engine/src/formats/markdown.js +++ b/packages/engine/src/formats/markdown.js @@ -1,7 +1,3 @@ -// we need to load the global-dom-shim as otherwise import { html } from 'lit'; breaks -// https://github.com/lit/lit/issues/2524 -import '@lit-labs/ssr/lib/install-global-dom-shim.js'; - /* eslint-disable @typescript-eslint/ban-ts-comment */ // @ts-ignore import { mdjsProcess } from '@mdjs/core'; diff --git a/packages/engine/src/index.js b/packages/engine/src/index.js index 71ace725..22093bd8 100644 --- a/packages/engine/src/index.js +++ b/packages/engine/src/index.js @@ -1,7 +1,3 @@ -// we need to load the global-dom-shim as otherwise import { html } from 'lit'; breaks -// https://github.com/lit/lit/issues/2524 -import '@lit-labs/ssr/lib/install-global-dom-shim.js'; - export { renderJoiningGroup } from './helpers/renderJoiningGroup.js'; export { inlineFile } from './helpers/inlineFile.js'; diff --git a/packages/engine/src/worker/importWorker.js b/packages/engine/src/worker/importWorker.js index dd656e2a..bf7199ad 100644 --- a/packages/engine/src/worker/importWorker.js +++ b/packages/engine/src/worker/importWorker.js @@ -1,7 +1,3 @@ -// we need to load the global-dom-shim as otherwise import { html } from 'lit'; breaks -// https://github.com/lit/lit/issues/2524 -import '@lit-labs/ssr/lib/install-global-dom-shim.js'; - import { parentPort } from 'worker_threads'; // import { convertMdFile, convertHtmlFile } from '../converts.js'; diff --git a/packages/engine/src/worker/renderWorker.js b/packages/engine/src/worker/renderWorker.js index 52a8d73c..76f97ad7 100644 --- a/packages/engine/src/worker/renderWorker.js +++ b/packages/engine/src/worker/renderWorker.js @@ -1,7 +1,3 @@ -// we need to load the global-dom-shim as otherwise import { html } from 'lit'; breaks -// https://github.com/lit/lit/issues/2524 -import '@lit-labs/ssr/lib/install-global-dom-shim.js'; - import path from 'path'; import { parentPort } from 'worker_threads'; import { mkdir, writeFile } from 'fs/promises'; diff --git a/packages/engine/test-node/04a-renderJoiningGroup.test.js b/packages/engine/test-node/04a-renderJoiningGroup.test.js index 383e1a44..67879977 100644 --- a/packages/engine/test-node/04a-renderJoiningGroup.test.js +++ b/packages/engine/test-node/04a-renderJoiningGroup.test.js @@ -1,5 +1,4 @@ import chai from 'chai'; -// import '@lit-labs/ssr/lib/install-global-dom-shim.js'; import { html } from 'lit'; import { renderJoiningGroup } from '../src/helpers/renderJoiningGroup.js'; import { testLitServerRender } from './test-helpers.js'; diff --git a/packages/launch/package.json b/packages/launch/package.json index 074df634..8fcb2325 100644 --- a/packages/launch/package.json +++ b/packages/launch/package.json @@ -50,7 +50,7 @@ "@rocket/components": "^0.2.0", "@rocket/engine": "^0.2.0", "@webcomponents/template-shadowroot": "^0.1.0", - "lit": "^2.2.5", + "lit": "^2.3.0", "workbox-window": "^6.1.5" }, "types": "./dist-types/src/index.d.ts", diff --git a/packages/mdjs-preview/package.json b/packages/mdjs-preview/package.json index a6fcdbd7..42e38277 100644 --- a/packages/mdjs-preview/package.json +++ b/packages/mdjs-preview/package.json @@ -36,7 +36,7 @@ "dependencies": { "@lion/accordion": "^0.9.0", "@open-wc/scoped-elements": "^2.0.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "types": "dist-types/index.d.ts" } diff --git a/packages/mdjs-story/package.json b/packages/mdjs-story/package.json index fe0caad8..4b4d9bc1 100644 --- a/packages/mdjs-story/package.json +++ b/packages/mdjs-story/package.json @@ -31,7 +31,7 @@ "src" ], "dependencies": { - "lit": "^2.2.5" + "lit": "^2.3.0" }, "types": "dist-types/index.d.ts" } diff --git a/presets/spark/package.json b/presets/spark/package.json index 9a89d6b3..5fb74ed0 100644 --- a/presets/spark/package.json +++ b/presets/spark/package.json @@ -42,7 +42,7 @@ "dependencies": { "@rocket/components": "^0.2.0", "@rocket/engine": "^0.2.0", - "lit": "^2.2.5" + "lit": "^2.3.0" }, "devDependencies": {}, "types": "./dist-types/src/index.d.ts", diff --git a/yarn.lock b/yarn.lock index f903afe9..e00d62bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1266,25 +1266,25 @@ lit "^2.0.0" lit-html "^2.0.0" -"@lit-labs/ssr@^2.0.4": - version "2.2.2" - resolved "https://registry.yarnpkg.com/@lit-labs/ssr/-/ssr-2.2.2.tgz#545ce760d4f3d50459221f56e516ad1c0bf5d1cd" - integrity sha512-pWyZurpOeOxueS5EXdWkZTM9fBEHfR70WJ3dAn4oE4iWRLpt6mwx9GvUWQF0oKHqi0tQP/WjfTRf+nafWWSTfw== +"@lit-labs/ssr@^2.2.3": + version "2.2.3" + resolved "https://registry.yarnpkg.com/@lit-labs/ssr/-/ssr-2.2.3.tgz#8f9cc343ebf531dd670136d342562bee33ce9be0" + integrity sha512-QOHZGR5a6znwqa8wM5hpMdlfO/fXUh0LYV39b16TEGtnszhGlKECx4+w9RiBuwOj/Qb5/SHGKpr81APRevWGeg== dependencies: "@lit-labs/ssr-client" "^1.0.0" - "@lit/reactive-element" "^1.1.0" + "@lit/reactive-element" "^1.4.0" "@types/node" "^16.0.0" - lit "^2.1.0" + lit "^2.3.0" lit-element "^3.1.0" - lit-html "^2.1.0" + lit-html "^2.3.0" node-fetch "^3.2.8" parse5 "^6.0.1" resolve "^1.10.1" -"@lit/reactive-element@^1.0.0", "@lit/reactive-element@^1.1.0", "@lit/reactive-element@^1.3.0": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-1.3.4.tgz#c4492a54387f7b1020d498a348403229583d1c06" - integrity sha512-I1wz4uxOA52zSBhKmv4KQWLJpCyvfpnDg+eQR6mjpRgV+Ldi14HLPpSUpJklZRldz0fFmGCC/kVmuc/3cPFqCg== +"@lit/reactive-element@^1.0.0", "@lit/reactive-element@^1.3.0", "@lit/reactive-element@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-1.4.0.tgz#78ed05eb9b750e8e3671a61a30c19198e4038f80" + integrity sha512-blrtlLKvtVyjTJ3gUHWNSHOU6tD8be9mRafqtnO7GVMcB+5z4RjNcO0DpMGmccK6N8yur1vVVYnS0gPdQ/WgEQ== "@manypkg/find-root@^1.1.0": version "1.1.0" @@ -5148,21 +5148,21 @@ lit-html@^1.1.1: resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.4.1.tgz#0c6f3ee4ad4eb610a49831787f0478ad8e9ae5e0" integrity sha512-B9btcSgPYb1q4oSOb/PrOT6Z/H+r6xuNzfH4lFli/AWhYwdtrgQkQWBbIc6mdnf6E2IL3gDXdkkqNktpU0OZQA== -lit-html@^2.0.0, lit-html@^2.1.0, lit-html@^2.2.0: - version "2.2.7" - resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-2.2.7.tgz#390a45589f55b95106da1f860b6aa2894ab34373" - integrity sha512-JhqiAwO1l03kRe68uBZ0i2x4ef2S5szY9vvP411nlrFZIpKK4/hwnhA/15bqbvxe1lV3ipBdhaOzHmyOk7QIRg== +lit-html@^2.0.0, lit-html@^2.2.0, lit-html@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-2.3.0.tgz#6896685744f0b1ddef0d39aa2092fcd06dfd169d" + integrity sha512-bnJneRqizoeSTxUeyDJLBDr+DI+7bn6P3WWqsj/4AwPWJjYgjSO5W64BVl1CrEo/8DtgU6DAYADX6yeI5/eDsg== dependencies: "@types/trusted-types" "^2.0.2" -lit@^2.0.0, lit@^2.0.2, lit@^2.1.0, lit@^2.2.5: - version "2.2.8" - resolved "https://registry.yarnpkg.com/lit/-/lit-2.2.8.tgz#26bdf560042aa3ec9b788f5d48119f7138b2dcc1" - integrity sha512-QjeNbi/H9LVIHR+u0OqsL+hs62a16m02JlJHYN48HcBuXyiPYR8JvzsTp5dYYS81l+b9Emp3UaGo82EheV0pog== +lit@^2.0.0, lit@^2.0.2, lit@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/lit/-/lit-2.3.0.tgz#611e122cbf9f34f1af0c1f3f791f886453bdcbde" + integrity sha512-ynSGsUYKSGN2weFQ1F3SZq0Ihlj+vr/3KAET//Yf8Tz86L7lZizlw9Px+ab5iN8Si4RkVoLqd9YtKQmjdyKHNg== dependencies: - "@lit/reactive-element" "^1.3.0" + "@lit/reactive-element" "^1.4.0" lit-element "^3.2.0" - lit-html "^2.2.0" + lit-html "^2.3.0" load-json-file@^4.0.0: version "4.0.0"