From ec376369a84d20bc3079800ae8e8296c96fcf627 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 8 Aug 2022 16:26:36 -0500 Subject: [PATCH] fix: ensure jsx does not reference server entrypoint (#4203) Co-authored-by: Nate Moore --- .changeset/slimy-parrots-exist.md | 5 +++++ packages/astro/src/jsx/babel.ts | 3 ++- packages/astro/src/runtime/server/index.ts | 2 -- packages/astro/src/runtime/server/jsx.ts | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/slimy-parrots-exist.md diff --git a/.changeset/slimy-parrots-exist.md b/.changeset/slimy-parrots-exist.md new file mode 100644 index 000000000..36e87c466 --- /dev/null +++ b/.changeset/slimy-parrots-exist.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Ensure JSX does not reference server entrypoint diff --git a/packages/astro/src/jsx/babel.ts b/packages/astro/src/jsx/babel.ts index 8850dadc1..3482bbf37 100644 --- a/packages/astro/src/jsx/babel.ts +++ b/packages/astro/src/jsx/babel.ts @@ -1,9 +1,10 @@ import type { PluginObj } from '@babel/core'; import * as t from '@babel/types'; import { pathToFileURL } from 'node:url'; -import { ClientOnlyPlaceholder } from '../runtime/server/index.js'; import type { PluginMetadata } from '../vite-plugin-astro/types'; +const ClientOnlyPlaceholder = 'astro-client-only'; + function isComponent(tagName: string) { return ( (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) || diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 9604d0b17..1304aca3e 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -34,8 +34,6 @@ import { Renderer } from './render/index.js'; import { addAttribute } from './render/index.js'; -export const ClientOnlyPlaceholder = 'astro-client-only'; - // Used in creating the component. aka the main export. export function createComponent(cb: AstroComponentFactory) { // Add a flag to this callback to mark it as an Astro component diff --git a/packages/astro/src/runtime/server/jsx.ts b/packages/astro/src/runtime/server/jsx.ts index 7bdafe7a2..6041d514d 100644 --- a/packages/astro/src/runtime/server/jsx.ts +++ b/packages/astro/src/runtime/server/jsx.ts @@ -2,7 +2,6 @@ import { SSRResult } from '../../@types/astro.js'; import { AstroJSX, isVNode } from '../../jsx-runtime/index.js'; import { - ClientOnlyPlaceholder, escapeHTML, HTMLString, markHTMLString, @@ -14,6 +13,8 @@ import { voidElementNames, } from './index.js'; +const ClientOnlyPlaceholder = 'astro-client-only'; + const skipAstroJSXCheck = new WeakSet(); let originalConsoleError: any; let consoleFilterRefs = 0;