Skip to content

Commit 0e6e5db

Browse files
committed
Bug: Revert script inject due to issues with Lit duplication causing hydration errors
1 parent 131cbbd commit 0e6e5db

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
## 5.3.0
3+
4+
### Changes
5+
- This reverts to using `before-hydration` from `5.1.x` releases. Astro 6 has landed `before-hydration` fix in [6.0.5](https://github.com/withastro/astro/releases/tag/astro%406.0.5), and this should be stable in older versions of Astro 5.
6+
27
## 5.2.0
38

49
### Changes

dist/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ function index_default() {
3232
"head-inline",
3333
readFileSync(new URL("../client-shim.min.js", import.meta.url), { encoding: "utf-8" })
3434
);
35-
injectScript(
36-
"head-inline",
37-
readFileSync(new URL("../hydration-support.min.js", import.meta.url), { encoding: "utf-8" })
38-
);
35+
injectScript("before-hydration", `import '@semantic-ui/astro-lit/hydration-support.js';`);
3936
addRenderer({
4037
name: "@semantic-ui/astro-lit",
4138
serverEntrypoint: "@semantic-ui/astro-lit/server.js",

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@semantic-ui/astro-lit",
3-
"version": "5.2.0",
3+
"version": "5.3.0",
44
"description": "Use Lit components with Astro",
55
"type": "module",
66
"types": "./dist/index.d.ts",
@@ -29,7 +29,6 @@
2929
"client-shim.js",
3030
"client-shim.min.js",
3131
"hydration-support.js",
32-
"hydration-support.min.js",
3332
"server.js",
3433
"server.d.ts",
3534
"server-shim.js"
@@ -38,9 +37,10 @@
3837
"build": "npm run build:js && npm run build:types && npm run build:minify",
3938
"build:js": "esbuild src/index.ts src/client.ts --format=esm --bundle --platform=node --outdir=dist",
4039
"build:types": "tsc src/client.ts --declaration --emitDeclarationOnly --skipLibCheck --outDir ./dist",
41-
"build:minify": "esbuild client-shim.js --minify --outfile=client-shim.min.js && esbuild hydration-support.js --bundle --format=iife --minify --outfile=hydration-support.min.js",
40+
"build:minify": "esbuild client-shim.js --minify --outfile=client-shim.min.js",
4241
"dev": "npm run build -- --watch",
43-
"test": "node test/server.test.js && node test/sass.test.js"
42+
"test": "node test/server.test.js && node test/sass.test.js",
43+
"prepublishOnly": "npm run build"
4444
},
4545
"dependencies": {
4646
"@lit-labs/ssr": "^3.3.1",

src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ export default function (): AstroIntegration {
3636
'head-inline',
3737
readFileSync(new URL('../client-shim.min.js', import.meta.url), { encoding: 'utf-8' })
3838
);
39-
// Inject hydration support as a blocking script to guarantee it runs
40-
// before any module scripts can load lit-element. This avoids a race
41-
// condition where lit-element evaluates before the hydration patches
42-
// are registered on globalThis.litElementHydrateSupport.
43-
injectScript(
44-
'head-inline',
45-
readFileSync(new URL('../hydration-support.min.js', import.meta.url), { encoding: 'utf-8' })
46-
);
39+
// Inject the hydration code, before a component is hydrated.
40+
injectScript('before-hydration', `import '@semantic-ui/astro-lit/hydration-support.js';`);
4741
// Add the lit renderer so that Astro can understand lit components.
4842
addRenderer({
4943
name: '@semantic-ui/astro-lit',

0 commit comments

Comments
 (0)