From b4b69cf4b5072943512407236fdb339ab7ef197c Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 11 Oct 2021 16:19:31 -0400 Subject: [PATCH] chore(plugin-react): skip `code.replace` call if no React alias exists --- packages/plugin-react/src/jsx-runtime/restore-jsx.ts | 4 ++++ 1 file changed, 4 insertions(+) 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'