Skip to content

Commit

Permalink
refactor: Drop Preact compat hack, remove incorrect alias (#10585)
Browse files Browse the repository at this point in the history
Co-authored-by: Arsh <[email protected]>
  • Loading branch information
rschristian and lilnasy authored Apr 1, 2024
1 parent 44b3c29 commit ad50784
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-books-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/preact": patch
---

Fixes (theoretical) edge case in Preact integration's JSX aliases
10 changes: 2 additions & 8 deletions packages/integrations/preact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down

0 comments on commit ad50784

Please sign in to comment.