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:
parent
44b3c29ce7
commit
ad50784adc
2 changed files with 7 additions and 8 deletions
5
.changeset/proud-books-hope.md
Normal file
5
.changeset/proud-books-hope.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/preact": patch
|
||||
---
|
||||
|
||||
Fixes (theoretical) edge case in Preact integration's JSX aliases
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue