From ad50784adc6f262fc563999e97df3a5dc9087c88 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Mon, 1 Apr 2024 03:53:59 -0500 Subject: [PATCH] refactor: Drop Preact compat hack, remove incorrect alias (#10585) Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com> --- .changeset/proud-books-hope.md | 5 +++++ packages/integrations/preact/src/index.ts | 10 ++-------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 .changeset/proud-books-hope.md diff --git a/.changeset/proud-books-hope.md b/.changeset/proud-books-hope.md new file mode 100644 index 000000000000..a330f58b62c7 --- /dev/null +++ b/.changeset/proud-books-hope.md @@ -0,0 +1,5 @@ +--- +"@astrojs/preact": patch +--- + +Fixes (theoretical) edge case in Preact integration's JSX aliases diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index a2264a990c4c..8de24d56548a 100644 --- a/packages/integrations/preact/src/index.ts +++ b/packages/integrations/preact/src/index.ts @@ -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