diff options
author | 2024-04-01 03:53:59 -0500 | |
---|---|---|
committer | 2024-04-01 16:53:59 +0800 | |
commit | ad50784adc6f262fc563999e97df3a5dc9087c88 (patch) | |
tree | f39082e230c605762886af8f5850a701ffe9c734 /packages/integrations/preact/src/index.ts | |
parent | 44b3c29ce7139dac61a39d83675cd01fe27e4bed (diff) | |
download | astro-ad50784adc6f262fc563999e97df3a5dc9087c88.tar.gz astro-ad50784adc6f262fc563999e97df3a5dc9087c88.tar.zst astro-ad50784adc6f262fc563999e97df3a5dc9087c88.zip |
refactor: Drop Preact compat hack, remove incorrect alias (#10585)
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r-- | packages/integrations/preact/src/index.ts | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index a2264a990..8de24d565 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 |