diff --git a/.github/workflows/test-multiple-versions.yml b/.github/workflows/test-multiple-versions.yml index 93feadbd0c..ebd5363630 100644 --- a/.github/workflows/test-multiple-versions.yml +++ b/.github/workflows/test-multiple-versions.yml @@ -52,6 +52,7 @@ jobs: run: | sed -i~ '1s/^/import React from "react";/' tests/*.tsx sed -i~ 's/automatic/classic/' babel.config.js + sed -i~ 's/automatic/classic/' .swcrc - name: Test ${{ matrix.react }} run: | yarn add -D react@${{ matrix.react }} react-dom@${{ matrix.react }} diff --git a/.swcrc b/.swcrc new file mode 100644 index 0000000000..b4e2d6a686 --- /dev/null +++ b/.swcrc @@ -0,0 +1,18 @@ +{ + "jsc": { + "target": "es5", + "parser": { + "syntax": "typescript", + "tsx": true + }, + "transform": { + "react": { + "runtime": "automatic", + "pragma": "React.createElement", + "pragmaFrag": "React.Fragment", + "throwIfNamespace": true, + "useBuiltins": true + } + } + } +} diff --git a/package.json b/package.json index 11486011ef..fb6043f3e5 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,11 @@ "jest": { "rootDir": ".", "testEnvironment": "jsdom", + "transform": { + "^.+\\.(t|j)sx?$": [ + "@swc/jest" + ] + }, "moduleNameMapper": { "^zustand$": "/src/index.ts", "^zustand/(.*)$": "/src/$1.ts" @@ -132,6 +137,8 @@ "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-node-resolve": "^13.0.6", "@rollup/plugin-typescript": "^8.3.0", + "@swc/core": "^1.2.115", + "@swc/jest": "^0.2.11", "@testing-library/react": "^12.1.2", "@types/jest": "^27.0.3", "@types/react": "^17.0.35", diff --git a/yarn.lock b/yarn.lock index 5fdd6feae5..471eaa152e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1039,6 +1039,13 @@ slash "^3.0.0" strip-ansi "^6.0.0" +"@jest/create-cache-key-function@^27.3.1": + version "27.4.2" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-27.4.2.tgz#09b585f9dbafec0f56cfb0e4d4edfe2bec0e0768" + integrity sha512-aSSCAJwUNX4R1hJQoyimsND5l+2EsFgzlepS8NuOJJHjXij/UdxYFngac44tmv9IYdI+kglAyORg0plt4/aFMQ== + dependencies: + "@jest/types" "^27.4.2" + "@jest/environment@^27.3.1": version "27.3.1" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.3.1.tgz#2182defbce8d385fd51c5e7c7050f510bd4c86b1" @@ -1162,6 +1169,29 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" +"@jest/types@^27.4.2": + version "27.4.2" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.4.2.tgz#96536ebd34da6392c2b7c7737d693885b5dd44a5" + integrity sha512-j35yw0PMTPpZsUoOBiuHzr1zTYoad1cVIE0ajEjcrJONxxrko/IRGKkXx3os0Nsi4Hu3+5VmDbVfq5WhG/pWAg== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^16.0.0" + chalk "^4.0.0" + +"@napi-rs/triples@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.3.tgz#76d6d0c3f4d16013c61e45dfca5ff1e6c31ae53c" + integrity sha512-jDJTpta+P4p1NZTFVLHJ/TLFVYVcOqv6l8xwOeBKNPMgY/zDYH/YH7SJbvrr/h1RcS9GzbPcLKGzpuK9cV56UA== + +"@node-rs/helper@^1.0.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@node-rs/helper/-/helper-1.2.1.tgz#e079b05f21ff4329d82c4e1f71c0290e4ecdc70c" + integrity sha512-R5wEmm8nbuQU0YGGmYVjEc0OHtYsuXdpRG+Ut/3wZ9XAvQWyThN08bTh2cBJgoZxHQUPtvRfeQuxcAgLuiBISg== + dependencies: + "@napi-rs/triples" "^1.0.3" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1242,6 +1272,93 @@ dependencies: "@sinonjs/commons" "^1.7.0" +"@swc/core-android-arm64@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.115.tgz#f4c3a464bb28e9da1e1154f0719ed8b2cea2af83" + integrity sha512-gFR5WloJC2/5J4qqxgXsDaBq86EQdBF+gxZ7YlksI34uMkcPeTUwY+i2+90oLJ9wKokxA+ZSinHSDhnoZcj17g== + +"@swc/core-darwin-arm64@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.115.tgz#30cbf6f4a2d2fb6d68df0de63fc90a7e5651b5d5" + integrity sha512-NAV8hWQ/9nCFL7gZtloj4GIj49HxNqzAONtILXVmJdpoMJCsa0I5JQqcYApj9TqJdsHWf5mKM2inlb547pJcbA== + +"@swc/core-darwin-x64@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.115.tgz#11cfd0539519fbae794f4a87a38c782da447116c" + integrity sha512-y1ZkBkDIF1Fp5SnFLMiERCTp6FTzdVqopNLSmCWnm5x+FtMxr/GI4408VcwzgwpT19zRevtoPPtr/oFYhfRGAg== + +"@swc/core-freebsd-x64@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.115.tgz#05f4c07d9bace093abce92c43602ed2d7145dfb0" + integrity sha512-KuQfiX/9eSbGT7udkZreJSLWkxkHxlUUJBjGE9Y9LMeETZnpH85fpUuOQdYWQENzBVilCTW4vrHasaVJAG1Y0A== + +"@swc/core-linux-arm-gnueabihf@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.115.tgz#22057192258a5b89dd878b8a92b19c7c9249d25f" + integrity sha512-NkflRvji0heBMigLgnRkb1tgnnfTcIreiPuvDekXdBv2TSry9sHxiOgB2J1m/jVN2dqzEAmBVi/Qi9093vNPRQ== + +"@swc/core-linux-arm64-gnu@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.115.tgz#824b6c12ce897c4554c693e05740a1f1a061cdd4" + integrity sha512-yL/xgVbgdViku1FBMBj0bsLigcP4m09tpXsDhexkb8PWZ+uwHvTaXvm5aR+9xzRgct+lgrw9unbawvnHHDDBsA== + +"@swc/core-linux-arm64-musl@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.115.tgz#0b8fce32f8271c1c8e324f5e089aaed503bfad06" + integrity sha512-1Zzyxg6WUI78dc/e5bcYZjwRYAVc6icg7iZmcqb/t7cYWKebjOucIHH4kI9fzPphduA5kkLsXvQmtbh4jn6ZWA== + +"@swc/core-linux-x64-gnu@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.115.tgz#be7580b088514fb637b45f538832b96c8b7d137e" + integrity sha512-WqWBbUupsE7xVbVuOlv9yBZAlsYgflDVhtovTQYEVPW0ye3Q9tgnw9f9vRm+NANfqwGztPaDhWWQcPfF6PrLPQ== + +"@swc/core-linux-x64-musl@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.115.tgz#e74fd6f41f004223406888a4a7480a8656f90a7d" + integrity sha512-ot/DRxAk/Bez91vFWSbqHcua4a531vCaLw1Obcf4X05UfBbKZyFfic5Z0dnP+Gj/J6/BMd8Mga/b60i/Ox5UsA== + +"@swc/core-win32-arm64-msvc@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.115.tgz#e3ffab4028a603aaf39b9edfd76f3c17ec23b579" + integrity sha512-TQFBdAo8ebxvkpHYnu0Emb80FeMA9xjMxrTgD9cq2q2HjUU7sDlurKNnkaEf5/Utu8hRmP/XVM3EDDifHJEjhw== + +"@swc/core-win32-ia32-msvc@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.115.tgz#885685f60b3ec7d40fa4ade79e9ac6a520c3bda7" + integrity sha512-XohgeaIUOnE+WU5g2EAJ4MkaqNEGIMTKI459z/7uVObXAg8Zwk0GRqFH2hyQCge/ts8rSSJYB9N60OLGHPI2mg== + +"@swc/core-win32-x64-msvc@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.115.tgz#96233925499bf050eb785b54a4c17ae3dab95a08" + integrity sha512-8qYZefGpua06monfbfpV/zJ3onxI2862HfjMTI3DaaR+v76bBbtrnX40fRtsIVTq0wYFf2uw+sdXOtXemipekA== + +"@swc/core@^1.2.115": + version "1.2.115" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.115.tgz#5815e913ce81668cc0283936011a7dbf72f9bc96" + integrity sha512-2CfrraHNVIYSP5zLjrIW3Ofa5dvROCl3QXv3JtgAVm5AMaDIy9TjClexuB3+vDeHiZ+PPHZ8PCYsTfiWs3lJmg== + dependencies: + "@node-rs/helper" "^1.0.0" + optionalDependencies: + "@swc/core-android-arm64" "^1.2.115" + "@swc/core-darwin-arm64" "^1.2.115" + "@swc/core-darwin-x64" "^1.2.115" + "@swc/core-freebsd-x64" "^1.2.115" + "@swc/core-linux-arm-gnueabihf" "^1.2.115" + "@swc/core-linux-arm64-gnu" "^1.2.115" + "@swc/core-linux-arm64-musl" "^1.2.115" + "@swc/core-linux-x64-gnu" "^1.2.115" + "@swc/core-linux-x64-musl" "^1.2.115" + "@swc/core-win32-arm64-msvc" "^1.2.115" + "@swc/core-win32-ia32-msvc" "^1.2.115" + "@swc/core-win32-x64-msvc" "^1.2.115" + +"@swc/jest@^0.2.11": + version "0.2.11" + resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.11.tgz#4e9f158747e61da556c46dc0b213f926b94b2068" + integrity sha512-2iYyhP3W6Kffs9bKHmrcALT2/SPIqfLlG8jPXvtNFvjIbapC+ChnqaqEl1rSm/iA8xk3xkhYLubohtGtNBWAmw== + dependencies: + "@jest/create-cache-key-function" "^27.3.1" + "@testing-library/dom@^8.0.0": version "8.11.1" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.11.1.tgz#03fa2684aa09ade589b460db46b4c7be9fc69753"