From 41a7c9ccfbc1a7bc60aec672056eac3966ddd036 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Sat, 13 Nov 2021 14:26:42 -0500 Subject: [PATCH] fix(plugin-react): uncompiled JSX in linked pkgs (#5669) --- packages/plugin-react/src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 316149c8452287..134df5fcb1db57 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -134,11 +134,12 @@ export default function viteReact(opts: Options = {}): PluginOption[] { // By reverse-compiling "React.createElement" calls into JSX, // React elements provided by dependencies will also use the // automatic runtime! - const [restoredAst, isCommonJS] = !isProjectFile - ? await restoreJSX(babel, code, id) - : [null, false] + const [restoredAst, isCommonJS] = + !isProjectFile && !isJSX + ? await restoreJSX(babel, code, id) + : [null, false] - if (isProjectFile || (ast = restoredAst)) { + if (isJSX || (ast = restoredAst)) { plugins.push([ await loadPlugin( '@babel/plugin-transform-react-jsx' +