Update React SWC Vite Plugin (#3368)

* Update React SWC vite plugin

* Rename plugin so that it follows vite docs
This commit is contained in:
Michał Droń 2023-03-17 10:44:00 +01:00 committed by GitHub
parent 51326e52c4
commit f585e2ab7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 264 additions and 51 deletions

309
package-lock.json generated
View file

@ -137,6 +137,7 @@
"@types/webappsec-credential-management": "^0.5.1", "@types/webappsec-credential-management": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0", "@typescript-eslint/parser": "^5.41.0",
"@vitejs/plugin-react-swc": "^3.2.0",
"babel-core": "^7.0.0-bridge.0", "babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.5.1", "babel-jest": "^27.5.1",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
@ -165,7 +166,6 @@
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0",
"vite-plugin-pwa": "^0.13.3", "vite-plugin-pwa": "^0.13.3",
"vite-plugin-sentry": "^1.1.6", "vite-plugin-sentry": "^1.1.6",
"vite-plugin-swc-react-refresh": "^2.2.1",
"workbox-cacheable-response": "^6.1.2", "workbox-cacheable-response": "^6.1.2",
"workbox-expiration": "^6.1.2", "workbox-expiration": "^6.1.2",
"workbox-precaching": "^6.1.2", "workbox-precaching": "^6.1.2",
@ -8493,13 +8493,11 @@
} }
}, },
"node_modules/@swc/core": { "node_modules/@swc/core": {
"version": "1.3.19", "version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.40.tgz",
"integrity": "sha512-ZQJ+NID24PQkPIHnbO2B68YNQ6aMEyDz6dcsZucpRK4r7+aPqQ2yVLaqFcQU9VcGMyo4JJydmokzyTr1roWPIQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0",
"bin": {
"swcx": "run_swcx.js"
},
"engines": { "engines": {
"node": ">=10" "node": ">=10"
}, },
@ -8508,25 +8506,26 @@
"url": "https://opencollective.com/swc" "url": "https://opencollective.com/swc"
}, },
"optionalDependencies": { "optionalDependencies": {
"@swc/core-darwin-arm64": "1.3.19", "@swc/core-darwin-arm64": "1.3.40",
"@swc/core-darwin-x64": "1.3.19", "@swc/core-darwin-x64": "1.3.40",
"@swc/core-linux-arm-gnueabihf": "1.3.19", "@swc/core-linux-arm-gnueabihf": "1.3.40",
"@swc/core-linux-arm64-gnu": "1.3.19", "@swc/core-linux-arm64-gnu": "1.3.40",
"@swc/core-linux-arm64-musl": "1.3.19", "@swc/core-linux-arm64-musl": "1.3.40",
"@swc/core-linux-x64-gnu": "1.3.19", "@swc/core-linux-x64-gnu": "1.3.40",
"@swc/core-linux-x64-musl": "1.3.19", "@swc/core-linux-x64-musl": "1.3.40",
"@swc/core-win32-arm64-msvc": "1.3.19", "@swc/core-win32-arm64-msvc": "1.3.40",
"@swc/core-win32-ia32-msvc": "1.3.19", "@swc/core-win32-ia32-msvc": "1.3.40",
"@swc/core-win32-x64-msvc": "1.3.19" "@swc/core-win32-x64-msvc": "1.3.40"
} }
}, },
"node_modules/@swc/core-darwin-arm64": { "node_modules/@swc/core-darwin-arm64": {
"version": "1.3.19", "version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.40.tgz",
"integrity": "sha512-x4JHshTVB2o5xOedLL54/jsKkfUlsMw25tNM5fWkehiKWXlQuxEasl5/roceAFETWm8mEESuL8pWgZaiyTDl4Q==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
"dev": true, "dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true, "optional": true,
"os": [ "os": [
"darwin" "darwin"
@ -8535,6 +8534,150 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/@swc/core-darwin-x64": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.40.tgz",
"integrity": "sha512-2QaW9HtlvatiQscQACVIyKtj+vAEFEC6Tn+8rqxm8ikYHUD33M/FVXGWEvMLTI7T3P25zjhs+toAlLsjHgfzQQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.40.tgz",
"integrity": "sha512-cJPgSg8222gezj5Db2S8PNvcALJLokvXqvFjyzRR253SMFFkq9JKWk0uwO3wg8i8jhe78xMB6EO6AteQqFWvCg==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.40.tgz",
"integrity": "sha512-s76n4/vpQzV7dpS703m1WnCxyG7OfGk+EeJf+KEl/m6KP7c5MHHOLOf8hpagI/QI1H8jb9j1ADqNu2C7tEUR8Q==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-musl": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.40.tgz",
"integrity": "sha512-aTkeImCq1WrkljAQNnqlbk/1ermotONkBl11GH7Ia+8yhsmgt8ZiNBIi0tJ5UjdfXDtnl58Iek43Vo8LWaPUKA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-gnu": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.40.tgz",
"integrity": "sha512-ZsfVlzXSXvNZBuK1fCrenoLSLVv0Zk7OdmkAG9cWN3bKkc/ynxO+6njXLEKWfv9bRfDBXhxifyHGOVOQlIFIAA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-musl": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.40.tgz",
"integrity": "sha512-5GgMuadbd6fhHg/+7W25i+9OQTW4nTMGECias0BNPlcW8nnohzSphpj5jLI/Ub5bWzMwE2hua6e2uiZ17rTySg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.40.tgz",
"integrity": "sha512-TqiK28eaK3YOKSp8iESlrrbSzDGRQqM0zR4hvCgfHwL4L1BPh/M0aIMC/vyYh2gqpz2quyNqgi/DxoZ2+WxlUg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.40.tgz",
"integrity": "sha512-PqtCXFs5+ZbrfFe1VZAcCl8k9h47wE65mKDhDvZ9/SQhXxZX2+f5mUGXuH4G5rA0CyijsVpHnpA/5rqE7f2Sxw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-x64-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.40.tgz",
"integrity": "sha512-73DGsjsJYSzmoRbfomPj5jcQawtK2H0bCDi/1wgfl8NKVOuzrq+PpaTry3lzx+gvTHxUX6mUHV22i7C9ITL74Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@szmarczak/http-timer": { "node_modules/@szmarczak/http-timer": {
"version": "4.0.5", "version": "4.0.5",
"dev": true, "dev": true,
@ -9968,6 +10111,18 @@
"resolved": "https://registry.npmjs.org/@vanilla-extract/css-utils/-/css-utils-0.1.3.tgz", "resolved": "https://registry.npmjs.org/@vanilla-extract/css-utils/-/css-utils-0.1.3.tgz",
"integrity": "sha512-PZAcHROlgtCUGI2y0JntdNwvPwCNyeVnkQu6KTYKdmxBbK3w72XJUmLFYapfaFfgami4I9CTLnrJTPdtmS3gpw==" "integrity": "sha512-PZAcHROlgtCUGI2y0JntdNwvPwCNyeVnkQu6KTYKdmxBbK3w72XJUmLFYapfaFfgami4I9CTLnrJTPdtmS3gpw=="
}, },
"node_modules/@vitejs/plugin-react-swc": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.2.0.tgz",
"integrity": "sha512-IcBoXL/mcH7JdQr/nfDlDwTdIaH8Rg7LpfQDF4nAht+juHWIuv6WhpKPCSfY4+zztAaB07qdBoFz1XCZsgo3pQ==",
"dev": true,
"dependencies": {
"@swc/core": "^1.3.35"
},
"peerDependencies": {
"vite": "^4"
}
},
"node_modules/@vue/compiler-core": { "node_modules/@vue/compiler-core": {
"version": "3.2.31", "version": "3.2.31",
"dev": true, "dev": true,
@ -34908,17 +35063,6 @@
"vite": "^2.6.0 || ^3.0.0 || ^4.0.0" "vite": "^2.6.0 || ^3.0.0 || ^4.0.0"
} }
}, },
"node_modules/vite-plugin-swc-react-refresh": {
"version": "2.2.1",
"dev": true,
"license": "MIT",
"dependencies": {
"@swc/core": "^1.3.10"
},
"peerDependencies": {
"vite": "^2 || ^3"
}
},
"node_modules/vite/node_modules/esbuild": { "node_modules/vite/node_modules/esbuild": {
"version": "0.15.15", "version": "0.15.15",
"dev": true, "dev": true,
@ -42323,23 +42467,90 @@
} }
}, },
"@swc/core": { "@swc/core": {
"version": "1.3.19", "version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.40.tgz",
"integrity": "sha512-ZQJ+NID24PQkPIHnbO2B68YNQ6aMEyDz6dcsZucpRK4r7+aPqQ2yVLaqFcQU9VcGMyo4JJydmokzyTr1roWPIQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@swc/core-darwin-arm64": "1.3.19", "@swc/core-darwin-arm64": "1.3.40",
"@swc/core-darwin-x64": "1.3.19", "@swc/core-darwin-x64": "1.3.40",
"@swc/core-linux-arm-gnueabihf": "1.3.19", "@swc/core-linux-arm-gnueabihf": "1.3.40",
"@swc/core-linux-arm64-gnu": "1.3.19", "@swc/core-linux-arm64-gnu": "1.3.40",
"@swc/core-linux-arm64-musl": "1.3.19", "@swc/core-linux-arm64-musl": "1.3.40",
"@swc/core-linux-x64-gnu": "1.3.19", "@swc/core-linux-x64-gnu": "1.3.40",
"@swc/core-linux-x64-musl": "1.3.19", "@swc/core-linux-x64-musl": "1.3.40",
"@swc/core-win32-arm64-msvc": "1.3.19", "@swc/core-win32-arm64-msvc": "1.3.40",
"@swc/core-win32-ia32-msvc": "1.3.19", "@swc/core-win32-ia32-msvc": "1.3.40",
"@swc/core-win32-x64-msvc": "1.3.19" "@swc/core-win32-x64-msvc": "1.3.40"
} }
}, },
"@swc/core-darwin-arm64": { "@swc/core-darwin-arm64": {
"version": "1.3.19", "version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.40.tgz",
"integrity": "sha512-x4JHshTVB2o5xOedLL54/jsKkfUlsMw25tNM5fWkehiKWXlQuxEasl5/roceAFETWm8mEESuL8pWgZaiyTDl4Q==",
"dev": true,
"optional": true
},
"@swc/core-darwin-x64": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.40.tgz",
"integrity": "sha512-2QaW9HtlvatiQscQACVIyKtj+vAEFEC6Tn+8rqxm8ikYHUD33M/FVXGWEvMLTI7T3P25zjhs+toAlLsjHgfzQQ==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm-gnueabihf": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.40.tgz",
"integrity": "sha512-cJPgSg8222gezj5Db2S8PNvcALJLokvXqvFjyzRR253SMFFkq9JKWk0uwO3wg8i8jhe78xMB6EO6AteQqFWvCg==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm64-gnu": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.40.tgz",
"integrity": "sha512-s76n4/vpQzV7dpS703m1WnCxyG7OfGk+EeJf+KEl/m6KP7c5MHHOLOf8hpagI/QI1H8jb9j1ADqNu2C7tEUR8Q==",
"dev": true,
"optional": true
},
"@swc/core-linux-arm64-musl": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.40.tgz",
"integrity": "sha512-aTkeImCq1WrkljAQNnqlbk/1ermotONkBl11GH7Ia+8yhsmgt8ZiNBIi0tJ5UjdfXDtnl58Iek43Vo8LWaPUKA==",
"dev": true,
"optional": true
},
"@swc/core-linux-x64-gnu": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.40.tgz",
"integrity": "sha512-ZsfVlzXSXvNZBuK1fCrenoLSLVv0Zk7OdmkAG9cWN3bKkc/ynxO+6njXLEKWfv9bRfDBXhxifyHGOVOQlIFIAA==",
"dev": true,
"optional": true
},
"@swc/core-linux-x64-musl": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.40.tgz",
"integrity": "sha512-5GgMuadbd6fhHg/+7W25i+9OQTW4nTMGECias0BNPlcW8nnohzSphpj5jLI/Ub5bWzMwE2hua6e2uiZ17rTySg==",
"dev": true,
"optional": true
},
"@swc/core-win32-arm64-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.40.tgz",
"integrity": "sha512-TqiK28eaK3YOKSp8iESlrrbSzDGRQqM0zR4hvCgfHwL4L1BPh/M0aIMC/vyYh2gqpz2quyNqgi/DxoZ2+WxlUg==",
"dev": true,
"optional": true
},
"@swc/core-win32-ia32-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.40.tgz",
"integrity": "sha512-PqtCXFs5+ZbrfFe1VZAcCl8k9h47wE65mKDhDvZ9/SQhXxZX2+f5mUGXuH4G5rA0CyijsVpHnpA/5rqE7f2Sxw==",
"dev": true,
"optional": true
},
"@swc/core-win32-x64-msvc": {
"version": "1.3.40",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.40.tgz",
"integrity": "sha512-73DGsjsJYSzmoRbfomPj5jcQawtK2H0bCDi/1wgfl8NKVOuzrq+PpaTry3lzx+gvTHxUX6mUHV22i7C9ITL74Q==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -43374,6 +43585,15 @@
"resolved": "https://registry.npmjs.org/@vanilla-extract/css-utils/-/css-utils-0.1.3.tgz", "resolved": "https://registry.npmjs.org/@vanilla-extract/css-utils/-/css-utils-0.1.3.tgz",
"integrity": "sha512-PZAcHROlgtCUGI2y0JntdNwvPwCNyeVnkQu6KTYKdmxBbK3w72XJUmLFYapfaFfgami4I9CTLnrJTPdtmS3gpw==" "integrity": "sha512-PZAcHROlgtCUGI2y0JntdNwvPwCNyeVnkQu6KTYKdmxBbK3w72XJUmLFYapfaFfgami4I9CTLnrJTPdtmS3gpw=="
}, },
"@vitejs/plugin-react-swc": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.2.0.tgz",
"integrity": "sha512-IcBoXL/mcH7JdQr/nfDlDwTdIaH8Rg7LpfQDF4nAht+juHWIuv6WhpKPCSfY4+zztAaB07qdBoFz1XCZsgo3pQ==",
"dev": true,
"requires": {
"@swc/core": "^1.3.35"
}
},
"@vue/compiler-core": { "@vue/compiler-core": {
"version": "3.2.31", "version": "3.2.31",
"dev": true, "dev": true,
@ -60426,13 +60646,6 @@
"@sentry/cli": "^2.3.1" "@sentry/cli": "^2.3.1"
} }
}, },
"vite-plugin-swc-react-refresh": {
"version": "2.2.1",
"dev": true,
"requires": {
"@swc/core": "^1.3.10"
}
},
"vm-browserify": { "vm-browserify": {
"version": "1.1.2", "version": "1.1.2",
"optional": true "optional": true

View file

@ -172,7 +172,7 @@
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0",
"vite-plugin-pwa": "^0.13.3", "vite-plugin-pwa": "^0.13.3",
"vite-plugin-sentry": "^1.1.6", "vite-plugin-sentry": "^1.1.6",
"vite-plugin-swc-react-refresh": "^2.2.1", "@vitejs/plugin-react-swc": "^3.2.0",
"workbox-cacheable-response": "^6.1.2", "workbox-cacheable-response": "^6.1.2",
"workbox-expiration": "^6.1.2", "workbox-expiration": "^6.1.2",
"workbox-precaching": "^6.1.2", "workbox-precaching": "^6.1.2",

View file

@ -1,5 +1,6 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill"; import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
import react from "@vitejs/plugin-react-swc";
import { copyFileSync } from "fs"; import { copyFileSync } from "fs";
import path from "path"; import path from "path";
import nodePolyfills from "rollup-plugin-polyfill-node"; import nodePolyfills from "rollup-plugin-polyfill-node";
@ -7,7 +8,6 @@ import { defineConfig, loadEnv } from "vite";
import { createHtmlPlugin } from "vite-plugin-html"; import { createHtmlPlugin } from "vite-plugin-html";
import { VitePWA } from "vite-plugin-pwa"; import { VitePWA } from "vite-plugin-pwa";
import viteSentry from "vite-plugin-sentry"; import viteSentry from "vite-plugin-sentry";
import { swcReactRefresh } from "vite-plugin-swc-react-refresh";
const copyOgImage = () => ({ const copyOgImage = () => ({
name: "copy-og-image", name: "copy-og-image",
@ -54,7 +54,7 @@ export default defineConfig(({ command, mode }) => {
SENTRY_ORG && SENTRY_PROJECT && SENTRY_DSN && SENTRY_AUTH_TOKEN; SENTRY_ORG && SENTRY_PROJECT && SENTRY_DSN && SENTRY_AUTH_TOKEN;
const plugins = [ const plugins = [
swcReactRefresh(), react(),
createHtmlPlugin({ createHtmlPlugin({
entry: "/index.tsx", entry: "/index.tsx",
template: "index.html", template: "index.html",