From 4843bff0d2deea68349901f80d5de59d22df7a9c Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 17 Aug 2023 09:01:50 -0400 Subject: [PATCH] Fix more conflicts --- packages/astro/package.json | 2 ++ packages/astro/src/assets/image-endpoint.ts | 6 +----- packages/integrations/react/src/index.ts | 20 ++++++++------------ pnpm-lock.yaml | 11 ++++++++++- 4 files changed, 21 insertions(+), 18 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,11 +4,12 @@ import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-re import { appendForwardSlash } from '@astrojs/internal-helpers/path'; import type * as vite from 'vite'; +export type ReactIntegrationOptions = Pick & { + experimentalReactChildren?: boolean; +}; + const FAST_REFRESH_PREAMBLE = react.preambleCode; - - - function getRenderer() { return { name: '@astrojs/react', @@ -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 & { - 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__`, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea24903d3..59f6b7d60 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -569,6 +569,9 @@ importers: html-escaper: specifier: ^3.0.3 version: 3.0.3 + http-cache-semantics: + specifier: ^4.1.1 + version: 4.1.1 js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -684,6 +687,9 @@ importers: '@types/html-escaper': specifier: ^3.0.0 version: 3.0.0 + '@types/http-cache-semantics': + specifier: ^4.0.1 + version: 4.0.1 '@types/js-yaml': specifier: ^4.0.5 version: 4.0.5 @@ -8522,6 +8528,10 @@ packages: resolution: {integrity: sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw==} dev: true + /@types/http-cache-semantics@4.0.1: + resolution: {integrity: sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==} + dev: true + /@types/is-ci@3.0.0: resolution: {integrity: sha512-Q0Op0hdWbYd1iahB+IFNQcWXFq4O0Q5MwQP7uN0souuQ4rPg1vEYcnIOfr1gY+M+6rc8FGoRaBO1mOOvL29sEQ==} dependencies: @@ -12309,7 +12319,6 @@ packages: /http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} - dev: true /http-errors@2.0.0: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}