Skip to content

Commit

Permalink
Fix more conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Aug 17, 2023
1 parent cbb77af commit 4843bff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 1 addition & 5 deletions packages/astro/src/assets/image-endpoint.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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:');
}
20 changes: 8 additions & 12 deletions packages/integrations/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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: [
Expand All @@ -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'],
Expand All @@ -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__`,
Expand Down
11 changes: 10 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4843bff

Please sign in to comment.