Skip to content

Commit 6cd8e1c

Browse files
fix: cross-platform postinstall patch — replace macOS-only sed with Node script
1 parent a791339 commit 6cd8e1c

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "astro build",
1111
"generate:props": "tsx scripts/extract-props.ts",
1212
"preview": "astro preview",
13-
"postinstall": "sed -i '' \"s/vnode.type !== ClientOnlyPlaceholder:/vnode.type !== ClientOnlyPlaceholder \\&\\& !vnode.type.includes('-'):/\" node_modules/astro/dist/runtime/server/jsx.js"
13+
"postinstall": "node scripts/patch-astro.mjs"
1414
},
1515
"dependencies": {
1616
"@astrojs/mdx": "^5.0.3",

scripts/patch-astro.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { readFileSync, writeFileSync } from 'node:fs';
2+
3+
const file = 'node_modules/astro/dist/runtime/server/jsx.js';
4+
const content = readFileSync(file, 'utf8');
5+
const patched = content.replace(
6+
'vnode.type !== ClientOnlyPlaceholder:',
7+
"vnode.type !== ClientOnlyPlaceholder && !vnode.type.includes('-'):"
8+
);
9+
10+
if (content === patched) {
11+
console.log('⚠️ Astro patch target not found — may already be fixed or changed');
12+
} else {
13+
writeFileSync(file, patched);
14+
console.log('✅ Patched astro JSX handler for custom element hydration');
15+
}

0 commit comments

Comments
 (0)