Description:
When using vite-plugin-conditional-compile in a Vite project with the vite:react-swc plugin,
an error occurs during the build process. The vite:react-swc plugin throws a syntax error.
Environment:
- vite: "^5.2.6"
- vite-plugin-conditional-compile: "^1.4.5"
- @vitejs/plugin-react-swc": "^3.6.0"
- Node: "20.10.0"
- pnpm: "8.15.5"
- OS: macOS 13.6.7
Steps to Reproduce:
- Install
vite-plugin-conditional-compile and vite-plugin-react-swc.
2.Use conditional compilation in a React component
import React from 'react';
import { Route } from 'react-router-dom';
import { Page } from '@debug/pages/Page';
const AppRoutes = () => {
return (
<>
{/* #if [DEV] */}
<Route path="/Page" element={<Page />} />
{/* #endif */}
<Route path="/Error" element={<ErrorPage />} />
</>
);
};
export default AppRoutes;
-
Run the Vite development server or build the project.
-
The following syntax error occurs during the build process:
Plugin: vite:react-swc
File: /path/to/project/src/app/AppRoutes.tsx:12:1
SyntaxError: Unexpected token (15:0)
13 |
14 |
> 15 | }
| ^
16 | </Route>
17 |
18 | <Route path="/Error" element={<ErrorPage />} />
Description:
When using
vite-plugin-conditional-compilein a Vite project with thevite:react-swcplugin,an error occurs during the build process. The
vite:react-swcplugin throws a syntax error.Environment:
Steps to Reproduce:
vite-plugin-conditional-compileandvite-plugin-react-swc.2.Use conditional compilation in a React component
Run the Vite development server or build the project.
The following syntax error occurs during the build process: