diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/astro/package.json | 2 | ||||
-rw-r--r-- | packages/astro/src/assets/image-endpoint.ts | 6 | ||||
-rw-r--r-- | packages/integrations/react/src/index.ts | 20 |
3 files changed, 11 insertions, 17 deletions
diff --git a/packages/astro/package.json b/packages/astro/package.json index 7739b7ee4..91c59100d 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -139,6 +139,7 @@ "fast-glob": "^3.2.12", "github-slugger": "^2.0.0", "gray-matter": "^4.0.3", + "http-cache-semantics": "^4.1.1", "html-escaper": "^3.0.3", "js-yaml": "^4.1.0", "kleur": "^4.1.4", @@ -180,6 +181,7 @@ "@types/estree": "^0.0.51", "@types/hast": "^2.3.4", "@types/html-escaper": "^3.0.0", + "@types/http-cache-semantics": "^4.0.1", "@types/js-yaml": "^4.0.5", "@types/mime": "^2.0.3", "@types/mocha": "^9.1.1", diff --git a/packages/astro/src/assets/image-endpoint.ts b/packages/astro/src/assets/image-endpoint.ts index d83517379..aa2baf0a5 100644 --- a/packages/astro/src/assets/image-endpoint.ts +++ b/packages/astro/src/assets/image-endpoint.ts @@ -1,7 +1,7 @@ import mime from 'mime/lite.js'; import type { APIRoute } from '../@types/astro.js'; import { etag } from './utils/etag.js'; -import { isRemotePath } from '../core/path.js'; +import { isRemotePath } from '@astrojs/internal-helpers/path'; import { getConfiguredImageService, isRemoteAllowed } from './internal.js'; // @ts-expect-error import { imageConfig } from 'astro:assets'; @@ -70,7 +70,3 @@ export const GET: APIRoute = async ({ request }) => { return new Response(`Server Error: ${err}`, { status: 500 }); } }; - -function isRemotePath(src: string) { - return /^(http|ftp|https|ws):?\/\//.test(src) || src.startsWith('data:'); -} diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts index a318bb4c2..712b98610 100644 --- a/packages/integrations/react/src/index.ts +++ b/packages/integrations/react/src/index.ts @@ -4,10 +4,11 @@ import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-re import { appendForwardSlash } from '@astrojs/internal-helpers/path'; import type * as vite from 'vite'; -const FAST_REFRESH_PREAMBLE = react.preambleCode; - - +export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & { + experimentalReactChildren?: boolean; +}; +const FAST_REFRESH_PREAMBLE = react.preambleCode; function getRenderer() { return { @@ -43,7 +44,7 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin { }; } -function getViteConfiguration(experimentalReactChildren: boolean, { include, exclude }: Options = {}) { +function getViteConfiguration({ include, exclude, experimentalReactChildren }: ReactIntegrationOptions = {}) { return { optimizeDeps: { include: [ @@ -63,7 +64,7 @@ function getViteConfiguration(experimentalReactChildren: boolean, { include, exc }, plugins: [ react({ include, exclude }), - optionsPlugin(experimentalReactChildren) + optionsPlugin(!!experimentalReactChildren) ], resolve: { dedupe: ['react', 'react-dom', 'react-dom/server'], @@ -84,22 +85,17 @@ function getViteConfiguration(experimentalReactChildren: boolean, { include, exc }; } -export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & { - experimentalReactChildren: boolean; -}; export default function ({ include, exclude, experimentalReactChildren -}: ReactIntegrationOptions = { - experimentalReactChildren: false -}): AstroIntegration { +}: ReactIntegrationOptions = {}): AstroIntegration { return { name: '@astrojs/react', hooks: { 'astro:config:setup': ({ config, command, addRenderer, updateConfig, injectScript }) => { addRenderer(getRenderer()); - updateConfig({ vite: getViteConfiguration(experimentalReactChildren, { include, exclude }) }); + updateConfig({ vite: getViteConfiguration({ include, exclude, experimentalReactChildren }) }); if (command === 'dev') { const preamble = FAST_REFRESH_PREAMBLE.replace( `__BASE__`, |