Skip to content

Commit ad50784

Browse files
rschristianlilnasy
andauthored
refactor: Drop Preact compat hack, remove incorrect alias (#10585)
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
1 parent 44b3c29 commit ad50784

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

.changeset/proud-books-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@astrojs/preact": patch
3+
---
4+
5+
Fixes (theoretical) edge case in Preact integration's JSX aliases

packages/integrations/preact/src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function ({ include, exclude, compat }: Options = {}): AstroInteg
2020
hooks: {
2121
'astro:config:setup': ({ addRenderer, updateConfig, command }) => {
2222
const preactPlugin = preact({
23+
reactAliasesEnabled: compat ?? false,
2324
include,
2425
exclude,
2526
babel: {
@@ -34,20 +35,13 @@ export default function ({ include, exclude, compat }: Options = {}): AstroInteg
3435
},
3536
};
3637

37-
// If not compat, delete the plugin that does it
38-
if (!compat) {
39-
const pIndex = preactPlugin.findIndex((p) => p.name == 'preact:config');
40-
if (pIndex >= 0) {
41-
preactPlugin.splice(pIndex, 1);
42-
}
43-
} else {
38+
if (compat) {
4439
viteConfig.optimizeDeps!.include!.push(
4540
'preact/compat',
4641
'preact/test-utils',
4742
'preact/compat/jsx-runtime'
4843
);
4944
viteConfig.resolve = {
50-
alias: [{ find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' }],
5145
dedupe: ['preact/compat', 'preact'],
5246
};
5347
// noExternal React entrypoints to be bundled, resolved, and aliased by Vite

0 commit comments

Comments
 (0)