summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2023-05-02 23:18:34 +0800
committerGravatar GitHub <noreply@github.com> 2023-05-02 23:18:34 +0800
commita8a319aef744a64647ee16c7d558d74de6864c6c (patch)
tree3c2379668a0652b33d1c4bf3164a081f2ee65e4c
parent8dd43db93f9466b50f8b635c693589c86ef762e3 (diff)
downloadastro-a8a319aef744a64647ee16c7d558d74de6864c6c.tar.gz
astro-a8a319aef744a64647ee16c7d558d74de6864c6c.tar.zst
astro-a8a319aef744a64647ee16c7d558d74de6864c6c.zip
Fix `astro-entry` error on build with multiple JSX frameworks (#6967)
-rw-r--r--.changeset/loud-bears-glow.md5
-rw-r--r--packages/astro/src/core/build/plugins/plugin-component-entry.ts2
-rw-r--r--packages/astro/src/vite-plugin-jsx/index.ts5
3 files changed, 10 insertions, 2 deletions
diff --git a/.changeset/loud-bears-glow.md b/.changeset/loud-bears-glow.md
new file mode 100644
index 000000000..05296cb82
--- /dev/null
+++ b/.changeset/loud-bears-glow.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix `astro-entry` error on build with multiple JSX frameworks
diff --git a/packages/astro/src/core/build/plugins/plugin-component-entry.ts b/packages/astro/src/core/build/plugins/plugin-component-entry.ts
index 441bd4eb2..444aa6a19 100644
--- a/packages/astro/src/core/build/plugins/plugin-component-entry.ts
+++ b/packages/astro/src/core/build/plugins/plugin-component-entry.ts
@@ -2,7 +2,7 @@ import type { Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';
-const astroEntryPrefix = '\0astro-entry:';
+export const astroEntryPrefix = '\0astro-entry:';
/**
* When adding hydrated or client:only components as Rollup inputs, sometimes we're not using all
diff --git a/packages/astro/src/vite-plugin-jsx/index.ts b/packages/astro/src/vite-plugin-jsx/index.ts
index 0903a0413..8cab3db9f 100644
--- a/packages/astro/src/vite-plugin-jsx/index.ts
+++ b/packages/astro/src/vite-plugin-jsx/index.ts
@@ -13,6 +13,7 @@ import babel from '@babel/core';
import * as colors from 'kleur/colors';
import path from 'path';
import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from '../content/index.js';
+import { astroEntryPrefix } from '../core/build/plugins/plugin-component-entry.js';
import { error } from '../core/logger/core.js';
import { removeQueryString } from '../core/path.js';
import { detectImportSource } from './import-source.js';
@@ -139,7 +140,9 @@ export default function jsx({ settings, logging }: AstroPluginJSXOptions): Plugi
},
async transform(code, id, opts) {
const ssr = Boolean(opts?.ssr);
- if (SPECIAL_QUERY_REGEX.test(id)) {
+ // Skip special queries and astro entries. We skip astro entries here as we know it doesn't contain
+ // JSX code, and also because we can't detect the import source to apply JSX transforms.
+ if (SPECIAL_QUERY_REGEX.test(id) || id.startsWith(astroEntryPrefix)) {
return null;
}
id = removeQueryString(id);