diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts index d246ec1cc15067..0d4f34eb2b8d00 100644 --- a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts @@ -11,6 +11,10 @@ export async function restoreJSX( filename: string ): Promise { const [reactAlias, isCommonJS] = parseReactAlias(code) + if (!reactAlias) { + return [null, false] + } + const reactJsxRE = new RegExp( '\\b' + reactAlias + '\\.(createElement|Fragment)\\b', 'g'