From f39c0524cf0b60b52dcfc77e260889f0e5502996 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 27 Mar 2024 14:11:10 -0500 Subject: [PATCH 1/4] refactor: Drop Preact compat hack, remove incorrect alias --- packages/integrations/preact/src/index.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index a2264a990c4c..9289a384b35e 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, 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 From a558b2816555ba1cdb32c19b8c3a4c93c6b22121 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 27 Mar 2024 14:31:39 -0500 Subject: [PATCH 2/4] docs: Add changeset --- .changeset/proud-books-hope.md | 5 +++++ 1 file changed, 5 insertions(+) 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..38a642eb84c8 --- /dev/null +++ b/.changeset/proud-books-hope.md @@ -0,0 +1,5 @@ +--- +"@astrojs/preact": patch +--- + +Fix (theoretical) edge case in Preact integration's JSX aliases From 2ac407c2c02a6bcd4bc73687c76fa77a1a27f00d Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:23:24 +0530 Subject: [PATCH 3/4] Apply suggestions from code review --- packages/integrations/preact/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index 9289a384b35e..8de24d56548a 100644 --- a/packages/integrations/preact/src/index.ts +++ b/packages/integrations/preact/src/index.ts @@ -20,7 +20,7 @@ export default function ({ include, exclude, compat }: Options = {}): AstroInteg hooks: { 'astro:config:setup': ({ addRenderer, updateConfig, command }) => { const preactPlugin = preact({ - reactAliasesEnabled: compat, + reactAliasesEnabled: compat ?? false, include, exclude, babel: { From 6644c1e88d299193cb0029f51b47bc071575d7b9 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 1 Apr 2024 16:53:17 +0800 Subject: [PATCH 4/4] Update .changeset/proud-books-hope.md --- .changeset/proud-books-hope.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/proud-books-hope.md b/.changeset/proud-books-hope.md index 38a642eb84c8..a330f58b62c7 100644 --- a/.changeset/proud-books-hope.md +++ b/.changeset/proud-books-hope.md @@ -2,4 +2,4 @@ "@astrojs/preact": patch --- -Fix (theoretical) edge case in Preact integration's JSX aliases +Fixes (theoretical) edge case in Preact integration's JSX aliases