diff options
Diffstat (limited to 'packages/integrations/preact')
-rw-r--r-- | packages/integrations/preact/CHANGELOG.md | 8 | ||||
-rw-r--r-- | packages/integrations/preact/package.json | 2 | ||||
-rw-r--r-- | packages/integrations/preact/src/index.ts | 20 |
3 files changed, 18 insertions, 12 deletions
diff --git a/packages/integrations/preact/CHANGELOG.md b/packages/integrations/preact/CHANGELOG.md index 184d1914e..bd27174ad 100644 --- a/packages/integrations/preact/CHANGELOG.md +++ b/packages/integrations/preact/CHANGELOG.md @@ -1,5 +1,13 @@ # @astrojs/preact +## 3.0.0-beta.1 + +### Major Changes + +- [#7924](https://github.com/withastro/astro/pull/7924) [`519a1c4e8`](https://github.com/withastro/astro/commit/519a1c4e8407c7abcb8d879b67a9f4b960652cae) Thanks [@matthewp](https://github.com/matthewp)! - New `include` and `exclude` config options + + The Preact integration now has new `include` and `exclude` config options. Use these if you want to use Preact alongside another JSX framework; include specifies files to be compiled for Preact and `exclude` does the opposite. + ## 3.0.0-beta.0 ### Major Changes diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index 5fefa53eb..90d54ec25 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/preact", "description": "Use Preact components within Astro", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index 153b9e1c3..9551f97eb 100644 --- a/packages/integrations/preact/src/index.ts +++ b/packages/integrations/preact/src/index.ts @@ -1,5 +1,5 @@ import type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro'; -import preact, {type PreactPluginOptions as VitePreactPluginOptions} from '@preact/preset-vite'; +import preact, { type PreactPluginOptions as VitePreactPluginOptions } from '@preact/preset-vite'; import { fileURLToPath } from 'node:url'; const babelCwd = new URL('../', import.meta.url); @@ -12,9 +12,9 @@ function getRenderer(development: boolean): AstroRenderer { }; } -export type Options =Pick<VitePreactPluginOptions, 'include' | 'exclude'> & { compat?: boolean }; +export type Options = Pick<VitePreactPluginOptions, 'include' | 'exclude'> & { compat?: boolean }; -export default function ({include, exclude, compat}: Options = {}): AstroIntegration { +export default function ({ include, exclude, compat }: Options = {}): AstroIntegration { return { name: '@astrojs/preact', hooks: { @@ -23,8 +23,8 @@ export default function ({include, exclude, compat}: Options = {}): AstroIntegra include, exclude, babel: { - cwd: fileURLToPath(babelCwd) - } + cwd: fileURLToPath(babelCwd), + }, }); const viteConfig: ViteUserConfig = { @@ -35,8 +35,8 @@ export default function ({include, exclude, compat}: Options = {}): AstroIntegra }; // If not compat, delete the plugin that does it - if(!compat) { - const pIndex = preactPlugin.findIndex(p => p.name == 'preact:config'); + if (!compat) { + const pIndex = preactPlugin.findIndex((p) => p.name == 'preact:config'); if (pIndex >= 0) { preactPlugin.splice(pIndex, 1); } @@ -44,12 +44,10 @@ export default function ({include, exclude, compat}: Options = {}): AstroIntegra viteConfig.optimizeDeps!.include!.push( 'preact/compat', 'preact/test-utils', - 'preact/compat/jsx-runtime', + 'preact/compat/jsx-runtime' ); viteConfig.resolve = { - alias: [ - { find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' }, - ], + alias: [{ find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' }], dedupe: ['preact/compat', 'preact'], }; // noExternal React entrypoints to be bundled, resolved, and aliased by Vite |