From 0c4857d6371494100bf81eeafe108a66e4eb7c26 Mon Sep 17 00:00:00 2001 From: "@NgDaddy" <81327266+NgDaddy@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:00:11 +0200 Subject: [PATCH] fix(react): enable vitejs-plugin-react-swc for swc compiler (#27457) ## Current Behavior see #27433 ## Expected Behavior see #27433 ## Related Issue(s) see #27433 Fixes # - if compiler is `swc`, `@vitejs/plugin-react-swc` is being imported; otherwise `@vitejs/plugin-react` is being imported Co-authored-by: Emily Xiong (cherry picked from commit 7f2c5565dedb8ed25d3f1aea5662a1fe155bfafb) --- packages/react/src/generators/library/library.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react/src/generators/library/library.ts b/packages/react/src/generators/library/library.ts index 8b50dc1f8b824..a730413dfbe4b 100644 --- a/packages/react/src/generators/library/library.ts +++ b/packages/react/src/generators/library/library.ts @@ -173,7 +173,11 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) { "'react-dom'", "'react/jsx-runtime'", ], - imports: [`import react from '@vitejs/plugin-react'`], + imports: [ + options.compiler === 'swc' + ? `import react from '@vitejs/plugin-react-swc'` + : `import react from '@vitejs/plugin-react'`, + ], plugins: ['react()'], }, true