From cc8eebbd3f8c1d06b6b6efe05b4b571fc9f5e73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allen=20Zhang=20=28=E5=BC=A0=E6=B6=9B=29?= Date: Thu, 24 Oct 2024 15:59:02 +0800 Subject: [PATCH] feat(canyon-platform): use swc --- packages/canyon-platform/package.json | 12 ++++----- packages/canyon-platform/vite.config.ts | 35 +++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/packages/canyon-platform/package.json b/packages/canyon-platform/package.json index 18169db8..f7a8398d 100644 --- a/packages/canyon-platform/package.json +++ b/packages/canyon-platform/package.json @@ -41,19 +41,16 @@ "tailwind-merge": "^2.5.4" }, "devDependencies": { + "@eslint/js": "^9.13.0", "@graphql-codegen/cli": "^5.0.3", "@graphql-codegen/client-preset": "^4.4.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@typescript-eslint/eslint-plugin": "^8.11.0", "@typescript-eslint/parser": "^8.11.0", - "@vitejs/plugin-react": "^4.3.3", + "@vitejs/plugin-react-swc": "^3.7.1", "autoprefixer": "^10.4.20", - "babel-plugin-canyon": "^1.8.79", - "babel-plugin-istanbul": "^7.0.0", - "@eslint/js": "^9.13.0", "eslint": "^9.13.0", - "globals": "^15.11.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jsx-a11y": "^6.10.1", @@ -62,8 +59,11 @@ "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.13", "eslint-plugin-simple-import-sort": "^12.1.1", + "globals": "^15.11.0", "postcss": "^8.4.47", "prettier": "^3.3.3", + "swc-plugin-canyon": "0.0.2-alpha.25", + "swc-plugin-coverage-instrument": "^0.0.25", "tailwindcss": "^3.4.14", "typescript": "^5.6.3", "unplugin-auto-import": "^0.18.3", @@ -71,4 +71,4 @@ "vite": "^5.4.10", "vite-plugin-pages": "^0.32.3" } -} \ No newline at end of file +} diff --git a/packages/canyon-platform/vite.config.ts b/packages/canyon-platform/vite.config.ts index d750d2ee..d96ac5e7 100644 --- a/packages/canyon-platform/vite.config.ts +++ b/packages/canyon-platform/vite.config.ts @@ -1,29 +1,30 @@ -import react from "@vitejs/plugin-react"; +import react from "@vitejs/plugin-react-swc"; import * as path from "path"; import AutoImport from "unplugin-auto-import/vite"; import AntdResolver from "unplugin-auto-import-antd"; import { defineConfig } from "vite"; import Pages from "vite-plugin-pages"; -const babelConfig = { - plugins: - process.env.NODE_ENV === "development" - ? [] - : [ - "istanbul", - [ - "canyon", - { - instrumentCwd: path.resolve(__dirname, "../.."), - }, - ], - ], -}; - export default defineConfig({ plugins: [ react({ - babel: babelConfig, + plugins: + process.env.NODE_ENV === "development" + ? [] + : [ + ["swc-plugin-coverage-instrument", {}], + [ + "swc-plugin-canyon", + { + projectID: process.env.CI_PROJECT_ID, + sha: process.env.CI_COMMIT_SHA, + dsn: process.env.DSN, + reporter: process.env.REPORTER, + branch: process.env.CI_COMMIT_BRANCH, + instrumentCwd: path.resolve(__dirname, "../.."), + }, + ], + ], }), AutoImport({ imports: ["react", "react-i18next", "react-router-dom"],