0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00

Fix astro-entry error on build with multiple JSX frameworks (#6967)

This commit is contained in:
Bjorn Lu 2023-05-02 23:18:34 +08:00 committed by GitHub
parent 8dd43db93f
commit a8a319aef7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix `astro-entry` error on build with multiple JSX frameworks

View file

@ -2,7 +2,7 @@ import type { Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from '../internal.js'; import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.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 * When adding hydrated or client:only components as Rollup inputs, sometimes we're not using all

View file

@ -13,6 +13,7 @@ import babel from '@babel/core';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import path from 'path'; import path from 'path';
import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from '../content/index.js'; 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 { error } from '../core/logger/core.js';
import { removeQueryString } from '../core/path.js'; import { removeQueryString } from '../core/path.js';
import { detectImportSource } from './import-source.js'; import { detectImportSource } from './import-source.js';
@ -139,7 +140,9 @@ export default function jsx({ settings, logging }: AstroPluginJSXOptions): Plugi
}, },
async transform(code, id, opts) { async transform(code, id, opts) {
const ssr = Boolean(opts?.ssr); 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; return null;
} }
id = removeQueryString(id); id = removeQueryString(id);