Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out vite-swc #2282

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Try out vite-swc
  • Loading branch information
Jonas-C committed Mar 14, 2024
commit 011fff4d6c00cfc0cf6176becacedd652676842d
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -19,3 +19,4 @@ scripts/.cache/
/playwright/.cache/
/e2e/.auth/
/.yarn/
/.swc/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ WORKDIR $APP_PATH
RUN yarn install --immutable

# Copy necessary source files for server and client build
COPY babel.config.cjs tsconfig.json vite.config.ts postcss.config.cjs index.html $APP_PATH/
COPY tsconfig.json vite.config.ts postcss.config.cjs index.html $APP_PATH/
COPY scripts $APP_PATH/scripts

COPY src $APP_PATH/src
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ What's in the box?

- React
- Express
- Vite + Babel (ES6)
- Vite + SWC (ES6)

### Dependencies

3 changes: 0 additions & 3 deletions babel.config.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -32,14 +32,14 @@
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@emotion/babel-plugin": "11.11.0",
"@emotion/eslint-plugin": "11.11.0",
"@emotion/jest": "11.11.0",
"@ndla/scripts": "^2.0.5",
"@ndla/types-backend": "^0.2.65",
"@ndla/types-embed": "^4.1.1",
"@ndla/types-taxonomy": "^1.0.22",
"@playwright/test": "^1.42.0",
"@swc/plugin-emotion": "^2.5.120",
"@tanstack/react-query-devtools": "^5.7.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
@@ -53,7 +53,7 @@
"@types/react": "^18.2.12",
"@types/react-dom": "^18.2.5",
"@types/uuid": "^9",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"concurrently": "^8.0.1",
"cross-env": "^7.0.3",
"esbuild": "^0.19.11",
20 changes: 9 additions & 11 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -6,23 +6,21 @@
*
*/

import { defineConfig, splitVendorChunkPlugin } from 'vite';
import react from '@vitejs/plugin-react';
import { defineConfig, splitVendorChunkPlugin } from "vite";
import react from "@vitejs/plugin-react-swc";

export default defineConfig(() => {
return {
test: {
include: ['src/**/__tests__/*-test.(js|jsx|ts|tsx)'],
environment: 'jsdom',
include: ["src/**/__tests__/*-test.(js|jsx|ts|tsx)"],
environment: "jsdom",
globals: true,
setupFiles: './src/__tests__/vitest.setup.ts',
setupFiles: "./src/__tests__/vitest.setup.ts",
},
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
configFile: './babel.config.cjs',
},
jsxImportSource: "@emotion/react",
plugins: [["@swc/plugin-emotion", { autoLabel: "always" }]],
}),
splitVendorChunkPlugin(),
],
@@ -38,8 +36,8 @@ export default defineConfig(() => {
],
},
build: {
assetsDir: 'static',
outDir: 'build/public',
assetsDir: "static",
outDir: "build/public",
sourcemap: true,
},
};
244 changes: 151 additions & 93 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/core@npm:^7.17.9, @babel/core@npm:^7.22.5, @babel/core@npm:^7.23.5":
"@babel/core@npm:^7.17.9, @babel/core@npm:^7.22.5":
version: 7.23.7
resolution: "@babel/core@npm:7.23.7"
dependencies:
@@ -158,13 +158,6 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-plugin-utils@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/helper-plugin-utils@npm:7.22.5"
checksum: 10c0/d2c4bfe2fa91058bcdee4f4e57a3f4933aed7af843acfd169cd6179fab8d13c1d636474ecabb2af107dc77462c7e893199aa26632bac1c6d7e025a17cbb9d20d
languageName: node
linkType: hard

"@babel/helper-simple-access@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/helper-simple-access@npm:7.22.5"
@@ -226,7 +219,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.6":
"@babel/parser@npm:^7.22.15, @babel/parser@npm:^7.23.6":
version: 7.23.6
resolution: "@babel/parser@npm:7.23.6"
bin:
@@ -235,28 +228,6 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx-self@npm:^7.23.3":
version: 7.23.3
resolution: "@babel/plugin-transform-react-jsx-self@npm:7.23.3"
dependencies:
"@babel/helper-plugin-utils": "npm:^7.22.5"
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 10c0/6b586508fc58998483d4ee93a7e784c4f4d2350e2633739cf1990b7ad172e13906f72382fdaf7f07b4e3c7e7555342634d392bdeb1a079bb64762c6368ca9a32
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx-source@npm:^7.23.3":
version: 7.23.3
resolution: "@babel/plugin-transform-react-jsx-source@npm:7.23.3"
dependencies:
"@babel/helper-plugin-utils": "npm:^7.22.5"
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 10c0/a3aad7cf738e9bfaddc26cdbb83bb9684c2e689d26fb0793d772af0c8da0cd25bb02523d192fbc6946c32143e56b472c1d33fa82466b3f2d3346e1ce8fe83cf6
languageName: node
linkType: hard

"@babel/runtime@npm:^7.12.0, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.19.4, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.22.5, @babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.4.5, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2":
version: 7.23.8
resolution: "@babel/runtime@npm:7.23.8"
@@ -295,7 +266,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.6, @babel/types@npm:^7.3.0, @babel/types@npm:^7.8.3":
"@babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.6, @babel/types@npm:^7.8.3":
version: 7.23.6
resolution: "@babel/types@npm:7.23.6"
dependencies:
@@ -590,7 +561,7 @@ __metadata:
languageName: node
linkType: hard

"@emotion/babel-plugin@npm:11.11.0, @emotion/babel-plugin@npm:^11.11.0":
"@emotion/babel-plugin@npm:^11.11.0":
version: 11.11.0
resolution: "@emotion/babel-plugin@npm:11.11.0"
dependencies:
@@ -2816,6 +2787,145 @@ __metadata:
languageName: node
linkType: hard

"@swc/core-darwin-arm64@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-darwin-arm64@npm:1.4.8"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@swc/core-darwin-x64@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-darwin-x64@npm:1.4.8"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@swc/core-linux-arm-gnueabihf@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.4.8"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard

"@swc/core-linux-arm64-gnu@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-linux-arm64-gnu@npm:1.4.8"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@swc/core-linux-arm64-musl@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-linux-arm64-musl@npm:1.4.8"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@swc/core-linux-x64-gnu@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-linux-x64-gnu@npm:1.4.8"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@swc/core-linux-x64-musl@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-linux-x64-musl@npm:1.4.8"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@swc/core-win32-arm64-msvc@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-win32-arm64-msvc@npm:1.4.8"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@swc/core-win32-ia32-msvc@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-win32-ia32-msvc@npm:1.4.8"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@swc/core-win32-x64-msvc@npm:1.4.8":
version: 1.4.8
resolution: "@swc/core-win32-x64-msvc@npm:1.4.8"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"@swc/core@npm:^1.3.107":
version: 1.4.8
resolution: "@swc/core@npm:1.4.8"
dependencies:
"@swc/core-darwin-arm64": "npm:1.4.8"
"@swc/core-darwin-x64": "npm:1.4.8"
"@swc/core-linux-arm-gnueabihf": "npm:1.4.8"
"@swc/core-linux-arm64-gnu": "npm:1.4.8"
"@swc/core-linux-arm64-musl": "npm:1.4.8"
"@swc/core-linux-x64-gnu": "npm:1.4.8"
"@swc/core-linux-x64-musl": "npm:1.4.8"
"@swc/core-win32-arm64-msvc": "npm:1.4.8"
"@swc/core-win32-ia32-msvc": "npm:1.4.8"
"@swc/core-win32-x64-msvc": "npm:1.4.8"
"@swc/counter": "npm:^0.1.2"
"@swc/types": "npm:^0.1.5"
peerDependencies:
"@swc/helpers": ^0.5.0
dependenciesMeta:
"@swc/core-darwin-arm64":
optional: true
"@swc/core-darwin-x64":
optional: true
"@swc/core-linux-arm-gnueabihf":
optional: true
"@swc/core-linux-arm64-gnu":
optional: true
"@swc/core-linux-arm64-musl":
optional: true
"@swc/core-linux-x64-gnu":
optional: true
"@swc/core-linux-x64-musl":
optional: true
"@swc/core-win32-arm64-msvc":
optional: true
"@swc/core-win32-ia32-msvc":
optional: true
"@swc/core-win32-x64-msvc":
optional: true
peerDependenciesMeta:
"@swc/helpers":
optional: true
checksum: 10c0/da9079e66d7de696bef2445ba5ba20c7be80b9132f56b7912f2359edab3caa02d334204e4663458771b1995e5556c0629de9427b55587cbac27de6b259c61932
languageName: node
linkType: hard

"@swc/counter@npm:^0.1.2, @swc/counter@npm:^0.1.3":
version: 0.1.3
resolution: "@swc/counter@npm:0.1.3"
checksum: 10c0/8424f60f6bf8694cfd2a9bca45845bce29f26105cda8cf19cdb9fd3e78dc6338699e4db77a89ae449260bafa1cc6bec307e81e7fb96dbf7dcfce0eea55151356
languageName: node
linkType: hard

"@swc/plugin-emotion@npm:^2.5.120":
version: 2.5.120
resolution: "@swc/plugin-emotion@npm:2.5.120"
dependencies:
"@swc/counter": "npm:^0.1.3"
checksum: 10c0/bc3fdb98b36d383d3225d55d1325a3e5687ab2bda0ddc5d79bcab940efeaabf4d27d69c41b2379196044e9a7639a5a26c9680a626a542b9686ef83857a8729a7
languageName: node
linkType: hard

"@swc/types@npm:^0.1.5":
version: 0.1.5
resolution: "@swc/types@npm:0.1.5"
checksum: 10c0/b35f93fe896a2240f6f10544e408f9648c2bd4bcff9bd8d022d9a6942d31cf859f86119fb0bbb04a12eefa1f6a6745ffc7d18f3a490d76d7b6a074a7c9608144
languageName: node
linkType: hard

"@tanstack/query-core@npm:5.7.2":
version: 5.7.2
resolution: "@tanstack/query-core@npm:5.7.2"
@@ -2985,47 +3095,6 @@ __metadata:
languageName: node
linkType: hard

"@types/babel__core@npm:^7.20.5":
version: 7.20.5
resolution: "@types/babel__core@npm:7.20.5"
dependencies:
"@babel/parser": "npm:^7.20.7"
"@babel/types": "npm:^7.20.7"
"@types/babel__generator": "npm:*"
"@types/babel__template": "npm:*"
"@types/babel__traverse": "npm:*"
checksum: 10c0/bdee3bb69951e833a4b811b8ee9356b69a61ed5b7a23e1a081ec9249769117fa83aaaf023bb06562a038eb5845155ff663e2d5c75dd95c1d5ccc91db012868ff
languageName: node
linkType: hard

"@types/babel__generator@npm:*":
version: 7.0.2
resolution: "@types/babel__generator@npm:7.0.2"
dependencies:
"@babel/types": "npm:^7.0.0"
checksum: 10c0/367401db2a42f19b1ebcdfbffacf29699d3a2f1fc029eef271de40a07e42aa6a7fb32c43f8689d5bc28580446dfebf165ae332d05246193dfe69d40729aad262
languageName: node
linkType: hard

"@types/babel__template@npm:*":
version: 7.0.2
resolution: "@types/babel__template@npm:7.0.2"
dependencies:
"@babel/parser": "npm:^7.1.0"
"@babel/types": "npm:^7.0.0"
checksum: 10c0/8da8d45b97eb420976811a168d3ace44ffa0d98fea8ec204c8502331ce94f2b05b7be15357b741cffe2ef8bbfa419e841af9faafe07dc5049b3a6f71efd6a41e
languageName: node
linkType: hard

"@types/babel__traverse@npm:*":
version: 7.11.1
resolution: "@types/babel__traverse@npm:7.11.1"
dependencies:
"@babel/types": "npm:^7.3.0"
checksum: 10c0/c452f245baec0cc89db61be781ed44b8451bac51cbfc4955e6f8113e523c125fc35e630d3aa4aaec32a930ab9a6c1c1d8100761d5ac94cba62ab10cba7c5ea59
languageName: node
linkType: hard

"@types/body-parser@npm:*":
version: 1.17.0
resolution: "@types/body-parser@npm:1.17.0"
@@ -3709,18 +3778,14 @@ __metadata:
languageName: node
linkType: hard

"@vitejs/plugin-react@npm:^4.2.1":
version: 4.2.1
resolution: "@vitejs/plugin-react@npm:4.2.1"
"@vitejs/plugin-react-swc@npm:^3.6.0":
version: 3.6.0
resolution: "@vitejs/plugin-react-swc@npm:3.6.0"
dependencies:
"@babel/core": "npm:^7.23.5"
"@babel/plugin-transform-react-jsx-self": "npm:^7.23.3"
"@babel/plugin-transform-react-jsx-source": "npm:^7.23.3"
"@types/babel__core": "npm:^7.20.5"
react-refresh: "npm:^0.14.0"
"@swc/core": "npm:^1.3.107"
peerDependencies:
vite: ^4.2.0 || ^5.0.0
checksum: 10c0/de1eec44d703f32e5b58e776328ca20793657fe991835d15b290230b19a2a08be5d31501d424279ae13ecfed28044c117b69d746891c8d9b92c69e8a8907e989
vite: ^4 || ^5
checksum: 10c0/aae7c02f390559d0fbfb6285f1ba80917493d2c4979315f62f90fa06fb19b0b40362717fac035cac726575fdb120f66c4094f27bea846e2009686d15bc8637ae
languageName: node
linkType: hard

@@ -5497,7 +5562,6 @@ __metadata:
"@dnd-kit/modifiers": "npm:^6.0.1"
"@dnd-kit/sortable": "npm:^7.0.2"
"@dnd-kit/utilities": "npm:^3.2.1"
"@emotion/babel-plugin": "npm:11.11.0"
"@emotion/eslint-plugin": "npm:11.11.0"
"@emotion/jest": "npm:11.11.0"
"@emotion/react": "npm:^11.11.1"
@@ -5538,6 +5602,7 @@ __metadata:
"@radix-ui/react-popover": "npm:^1.0.3"
"@radix-ui/react-portal": "npm:^1.0.3"
"@radix-ui/react-toolbar": "npm:^1.0.4"
"@swc/plugin-emotion": "npm:^2.5.120"
"@tanstack/react-query": "npm:5.7.2"
"@tanstack/react-query-devtools": "npm:^5.7.2"
"@testing-library/jest-dom": "npm:^6.4.2"
@@ -5552,7 +5617,7 @@ __metadata:
"@types/react": "npm:^18.2.12"
"@types/react-dom": "npm:^18.2.5"
"@types/uuid": "npm:^9"
"@vitejs/plugin-react": "npm:^4.2.1"
"@vitejs/plugin-react-swc": "npm:^3.6.0"
auth0-js: "npm:^9.22.1"
body-parser: "npm:^1.19.0"
buffer: "npm:^6.0.3"
@@ -10841,13 +10906,6 @@ __metadata:
languageName: node
linkType: hard

"react-refresh@npm:^0.14.0":
version: 0.14.0
resolution: "react-refresh@npm:0.14.0"
checksum: 10c0/b8ae07ad153357d77830928a7f1fc2df837aabefee907fa273ba04c7643f3b860e986f1d4b7ada9b721c8d79b8c24b5b911a314a1a2398b105f1b13d19ea2b8d
languageName: node
linkType: hard

"react-remove-scroll-bar@npm:^2.3.3":
version: 2.3.4
resolution: "react-remove-scroll-bar@npm:2.3.4"