0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

refactor: Drop Preact compat hack, remove incorrect alias (#10585)

Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
This commit is contained in:
Ryan Christian 2024-04-01 03:53:59 -05:00 committed by GitHub
parent 44b3c29ce7
commit ad50784adc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 8 deletions

View file

@ -0,0 +1,5 @@
---
"@astrojs/preact": patch
---
Fixes (theoretical) edge case in Preact integration's JSX aliases

View file

@ -20,6 +20,7 @@ export default function ({ include, exclude, compat }: Options = {}): AstroInteg
hooks: {
'astro:config:setup': ({ addRenderer, updateConfig, command }) => {
const preactPlugin = preact({
reactAliasesEnabled: compat ?? false,
include,
exclude,
babel: {
@ -34,20 +35,13 @@ export default function ({ include, exclude, compat }: Options = {}): AstroInteg
},
};
// If not compat, delete the plugin that does it
if (!compat) {
const pIndex = preactPlugin.findIndex((p) => p.name == 'preact:config');
if (pIndex >= 0) {
preactPlugin.splice(pIndex, 1);
}
} else {
if (compat) {
viteConfig.optimizeDeps!.include!.push(
'preact/compat',
'preact/test-utils',
'preact/compat/jsx-runtime'
);
viteConfig.resolve = {
alias: [{ find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' }],
dedupe: ['preact/compat', 'preact'],
};
// noExternal React entrypoints to be bundled, resolved, and aliased by Vite