Skip to content

Commit

Permalink
Fix astro-entry error on build with multiple JSX frameworks (#6967)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored May 2, 2023
1 parent 8dd43db commit a8a319a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-bears-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix `astro-entry` error on build with multiple JSX frameworks
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/vite-plugin-jsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a8a319a

Please sign in to comment.