From 1609a3438184f244b2c33970c81327e402d865b3 Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 20 Jun 2025 17:40:23 +0800 Subject: [PATCH 1/4] feat: integrate swc/react-compiler into rspack examples --- pnpm-lock.yaml | 116 ++++++++++++++++++ rspack/react-compiler-babel-ts/package.json | 1 + .../react-compiler-babel-ts/rspack.config.js | 11 +- rspack/react-compiler-babel/package.json | 1 + rspack/react-compiler-babel/rspack.config.js | 8 ++ 5 files changed, 134 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa795e53..586eddde 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2164,6 +2164,9 @@ importers: '@rspack/core': specifier: 1.3.15 version: 1.3.15(@swc/helpers@0.5.17) + '@swc/react-compiler': + specifier: 1.12.4 + version: 1.12.4 babel-loader: specifier: ^10.0.0 version: 10.0.0(@babel/core@7.27.4)(webpack@5.99.9(esbuild@0.24.2)) @@ -2198,6 +2201,9 @@ importers: '@rspack/core': specifier: 1.3.15 version: 1.3.15(@swc/helpers@0.5.17) + '@swc/react-compiler': + specifier: 1.12.4 + version: 1.12.4 '@types/react': specifier: ^19.1.8 version: 19.1.8 @@ -6491,6 +6497,70 @@ packages: '@swc/plugin-transform-imports@6.5.2': resolution: {integrity: sha512-NmkCac1oZSwyTy8MzIZMCbyzF8afx1+Qt+frTC3N238jyfpLGntgh7cggvcbEKtZoC2BDo7tzMfxLHSQDF1KSw==} + '@swc/react-compiler-darwin-arm64@1.12.4': + resolution: {integrity: sha512-bSxDnobfFIw5ICPtUxokOwz6PF7SYQdY3awkz1CHkJaeyEkJLnJCHYOmB0SpHp73ZmCouzWq34u9yx+O11UGBg==} + engines: {node: '>=10'} + cpu: [arm64] + os: [darwin] + + '@swc/react-compiler-darwin-x64@1.12.4': + resolution: {integrity: sha512-8lsL40FPSYSoF5yqoF+1sAZkpY3paFoz5g4EuDTYseYm9fMx3LyXcTDfRb6+O2tsximPM/447rG/l1h0g7ljCA==} + engines: {node: '>=10'} + cpu: [x64] + os: [darwin] + + '@swc/react-compiler-linux-arm-gnueabihf@1.12.4': + resolution: {integrity: sha512-j2E48st7UNzrB4xEt5hqfzb7F8rxAtklTF7O6KWcYDhD48iHcZCLHuj4AQ8LV10T8yRuWrNsSD6nWuzETynWNg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@swc/react-compiler-linux-arm64-gnu@1.12.4': + resolution: {integrity: sha512-+irP1garMjYVCpP1wP1MRO2Mpr6SxyTP/b2KXTRc6teIti6BqPU5PENrdRd/yFcjxtNDmzDFPi1NdAMt6nv1kg==} + engines: {node: '>=10'} + cpu: [arm64] + os: [linux] + + '@swc/react-compiler-linux-arm64-musl@1.12.4': + resolution: {integrity: sha512-uD7qLqafic2Q4zw1a3bbxZBBCZ3m0xst2LJLXrzr0fcEDs7RdFmHhacHPNQwVNY3fsyep8HCLq9P1xOJx7Y49w==} + engines: {node: '>=10'} + cpu: [arm64] + os: [linux] + + '@swc/react-compiler-linux-x64-gnu@1.12.4': + resolution: {integrity: sha512-8SyWClpJivi1LUZFawYEWqMATlW/Rd6M3dTVh3Cir4kwiAIjC5WhaoYGz9+N7itK+/Fhb44B2Soqd4wVgylb1Q==} + engines: {node: '>=10'} + cpu: [x64] + os: [linux] + + '@swc/react-compiler-linux-x64-musl@1.12.4': + resolution: {integrity: sha512-ixz+vQPOkhWRnHEfelrAqoiJggwEjzsJi8KNxr8vcx+pG63TEN+QMM3vhC7UFkuiuKSDzzh0A1yPBki0b9gTlA==} + engines: {node: '>=10'} + cpu: [x64] + os: [linux] + + '@swc/react-compiler-win32-arm64-msvc@1.12.4': + resolution: {integrity: sha512-h28OhDfjC4CeRYLv27+vgiloZj4ACFRf3vm1v2hfcRfdD8vmYgxis2KXMd27JIoSTbXIzVlxf97FT26U2Q6bHw==} + engines: {node: '>=10'} + cpu: [arm64] + os: [win32] + + '@swc/react-compiler-win32-ia32-msvc@1.12.4': + resolution: {integrity: sha512-U0BzBLMWn95EnQWA/nqjZ5ZvqRPrjnAmuULmWXkZFX+oUNAfjjPyDyumDVqik7XVw/f/1LdGICZjw3S/A6vHUg==} + engines: {node: '>=10'} + cpu: [ia32] + os: [win32] + + '@swc/react-compiler-win32-x64-msvc@1.12.4': + resolution: {integrity: sha512-R/tYdzXYK4rMTpChkSfAnuMBBaUuuO4Morhf73u+ytOpicUahwP6STwlew5APjQ7pwAao//val/l8N/OO6v2Rw==} + engines: {node: '>=10'} + cpu: [x64] + os: [win32] + + '@swc/react-compiler@1.12.4': + resolution: {integrity: sha512-BsYk4ulWO2c3aRU9qYaj6VjczJ/PrteplK6UaqGD9AtmtDszf+oQfAvFROQhko9y+CcSNfXYNyWDh92UY03Iww==} + engines: {node: '>=20'} + '@swc/types@0.1.23': resolution: {integrity: sha512-u1iIVZV9Q0jxY+yM2vw/hZGDNudsN85bBpTqzAQ9rzkxW9D+e3aEM4Han+ow518gSewkXgjmEK0BD79ZcNVgPw==} @@ -19123,6 +19193,52 @@ snapshots: dependencies: '@swc/counter': 0.1.3 + '@swc/react-compiler-darwin-arm64@1.12.4': + optional: true + + '@swc/react-compiler-darwin-x64@1.12.4': + optional: true + + '@swc/react-compiler-linux-arm-gnueabihf@1.12.4': + optional: true + + '@swc/react-compiler-linux-arm64-gnu@1.12.4': + optional: true + + '@swc/react-compiler-linux-arm64-musl@1.12.4': + optional: true + + '@swc/react-compiler-linux-x64-gnu@1.12.4': + optional: true + + '@swc/react-compiler-linux-x64-musl@1.12.4': + optional: true + + '@swc/react-compiler-win32-arm64-msvc@1.12.4': + optional: true + + '@swc/react-compiler-win32-ia32-msvc@1.12.4': + optional: true + + '@swc/react-compiler-win32-x64-msvc@1.12.4': + optional: true + + '@swc/react-compiler@1.12.4': + dependencies: + '@swc/counter': 0.1.3 + '@swc/types': 0.1.23 + optionalDependencies: + '@swc/react-compiler-darwin-arm64': 1.12.4 + '@swc/react-compiler-darwin-x64': 1.12.4 + '@swc/react-compiler-linux-arm-gnueabihf': 1.12.4 + '@swc/react-compiler-linux-arm64-gnu': 1.12.4 + '@swc/react-compiler-linux-arm64-musl': 1.12.4 + '@swc/react-compiler-linux-x64-gnu': 1.12.4 + '@swc/react-compiler-linux-x64-musl': 1.12.4 + '@swc/react-compiler-win32-arm64-msvc': 1.12.4 + '@swc/react-compiler-win32-ia32-msvc': 1.12.4 + '@swc/react-compiler-win32-x64-msvc': 1.12.4 + '@swc/types@0.1.23': dependencies: '@swc/counter': 0.1.3 diff --git a/rspack/react-compiler-babel-ts/package.json b/rspack/react-compiler-babel-ts/package.json index 4bf0af5b..a8276e59 100644 --- a/rspack/react-compiler-babel-ts/package.json +++ b/rspack/react-compiler-babel-ts/package.json @@ -19,6 +19,7 @@ "@babel/plugin-syntax-typescript": "^7.27.1", "@rspack/cli": "1.3.15", "@rspack/core": "1.3.15", + "@swc/react-compiler": "1.12.4", "@types/react": "^19.1.8", "@types/react-dom": "^19.1.6", "babel-loader": "^10.0.0", diff --git a/rspack/react-compiler-babel-ts/rspack.config.js b/rspack/react-compiler-babel-ts/rspack.config.js index 197c9a94..d5cabb45 100644 --- a/rspack/react-compiler-babel-ts/rspack.config.js +++ b/rspack/react-compiler-babel-ts/rspack.config.js @@ -1,4 +1,7 @@ const { rspack } = require('@rspack/core'); +const fs = require('node:fs'); +const { isReactCompilerRequiredSync } = require('@swc/react-compiler'); + /** @type {import('@rspack/cli').Configuration} */ const config = { entry: { @@ -30,6 +33,11 @@ const config = { }, ], }, + { + test: (resouce) => + /\.(jsx|tsx)$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + loader: 'babel-loader', + }, { test: /\.(jsx|tsx)$/, use: [ @@ -51,9 +59,6 @@ const config = { }, }, }, - { - loader: 'babel-loader', - }, ], }, { diff --git a/rspack/react-compiler-babel/package.json b/rspack/react-compiler-babel/package.json index 1c990bc6..7919c027 100644 --- a/rspack/react-compiler-babel/package.json +++ b/rspack/react-compiler-babel/package.json @@ -18,6 +18,7 @@ "@babel/plugin-syntax-jsx": "^7.27.1", "@rspack/cli": "1.3.15", "@rspack/core": "1.3.15", + "@swc/react-compiler": "1.12.4", "babel-loader": "^10.0.0", "babel-plugin-react-compiler": "0.0.0-experimental-cd3852a-20241229" } diff --git a/rspack/react-compiler-babel/rspack.config.js b/rspack/react-compiler-babel/rspack.config.js index 46ddd0dd..269eed45 100644 --- a/rspack/react-compiler-babel/rspack.config.js +++ b/rspack/react-compiler-babel/rspack.config.js @@ -1,4 +1,7 @@ const { rspack } = require('@rspack/core'); +const fs = require('node:fs'); +const { isReactCompilerRequiredSync } = require('@swc/react-compiler'); + /** @type {import('@rspack/cli').Configuration} */ const config = { entry: { @@ -30,6 +33,11 @@ const config = { }, ], }, + { + test: (resouce) => + /\.jsx$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + loader: 'babel-loader', + }, { test: /\.jsx$/, use: [ From be86d663b3c41eb0944252a1fb8de0edd054dcae Mon Sep 17 00:00:00 2001 From: GiveMe-A-Name Date: Fri, 27 Jun 2025 16:02:49 +0800 Subject: [PATCH 2/4] feat: update @swc/react-compiler to v1.12.7 and fix sourceMap option in configurations --- pnpm-lock.yaml | 121 +++++++++--------- rspack/react-compiler-babel-ts/package.json | 2 +- .../react-compiler-babel-ts/rspack.config.js | 14 +- rspack/react-compiler-babel/package.json | 2 +- rspack/react-compiler-babel/rspack.config.js | 17 +-- 5 files changed, 80 insertions(+), 76 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 586eddde..1742889c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2165,14 +2165,14 @@ importers: specifier: 1.3.15 version: 1.3.15(@swc/helpers@0.5.17) '@swc/react-compiler': - specifier: 1.12.4 - version: 1.12.4 + specifier: 1.12.7 + version: 1.12.7 babel-loader: specifier: ^10.0.0 version: 10.0.0(@babel/core@7.27.4)(webpack@5.99.9(esbuild@0.24.2)) babel-plugin-react-compiler: - specifier: 0.0.0-experimental-cd3852a-20241229 - version: 0.0.0-experimental-cd3852a-20241229 + specifier: 19.1.0-rc.2 + version: 19.1.0-rc.2 rspack/react-compiler-babel-ts: dependencies: @@ -2202,8 +2202,8 @@ importers: specifier: 1.3.15 version: 1.3.15(@swc/helpers@0.5.17) '@swc/react-compiler': - specifier: 1.12.4 - version: 1.12.4 + specifier: 1.12.7 + version: 1.12.7 '@types/react': specifier: ^19.1.8 version: 19.1.8 @@ -6497,68 +6497,68 @@ packages: '@swc/plugin-transform-imports@6.5.2': resolution: {integrity: sha512-NmkCac1oZSwyTy8MzIZMCbyzF8afx1+Qt+frTC3N238jyfpLGntgh7cggvcbEKtZoC2BDo7tzMfxLHSQDF1KSw==} - '@swc/react-compiler-darwin-arm64@1.12.4': - resolution: {integrity: sha512-bSxDnobfFIw5ICPtUxokOwz6PF7SYQdY3awkz1CHkJaeyEkJLnJCHYOmB0SpHp73ZmCouzWq34u9yx+O11UGBg==} + '@swc/react-compiler-darwin-arm64@1.12.7': + resolution: {integrity: sha512-/YTWN0kPTVEZ1Q9VcZMYc4NtYGds3/OMnPa/FF7c5P92qtclTFCXgZifdBZN5D6S62LRwvisev/2yJ2VmZcJmA==} engines: {node: '>=10'} cpu: [arm64] os: [darwin] - '@swc/react-compiler-darwin-x64@1.12.4': - resolution: {integrity: sha512-8lsL40FPSYSoF5yqoF+1sAZkpY3paFoz5g4EuDTYseYm9fMx3LyXcTDfRb6+O2tsximPM/447rG/l1h0g7ljCA==} + '@swc/react-compiler-darwin-x64@1.12.7': + resolution: {integrity: sha512-JpnrQ9/pOE6inWX/T187ScwqGjzPTlZx4VKEInzssC8PERG35jZFRweP9pf38BKHTVq2BQznKOT4o8/+ek12Jw==} engines: {node: '>=10'} cpu: [x64] os: [darwin] - '@swc/react-compiler-linux-arm-gnueabihf@1.12.4': - resolution: {integrity: sha512-j2E48st7UNzrB4xEt5hqfzb7F8rxAtklTF7O6KWcYDhD48iHcZCLHuj4AQ8LV10T8yRuWrNsSD6nWuzETynWNg==} + '@swc/react-compiler-linux-arm-gnueabihf@1.12.7': + resolution: {integrity: sha512-beBAWmt4I8oPKA3Lm4DchbeI97imNXIUtSkmJxuy86M4kVTYHgkFWwjHedn2Adx1sJF/Q9RMmWHvgmpGt6wb+g==} engines: {node: '>=12'} cpu: [arm] os: [linux] - '@swc/react-compiler-linux-arm64-gnu@1.12.4': - resolution: {integrity: sha512-+irP1garMjYVCpP1wP1MRO2Mpr6SxyTP/b2KXTRc6teIti6BqPU5PENrdRd/yFcjxtNDmzDFPi1NdAMt6nv1kg==} + '@swc/react-compiler-linux-arm64-gnu@1.12.7': + resolution: {integrity: sha512-+YtNKIuJBj+t2wYlVf0w5sXuWo1X8l5Hb+SH4vlILkgTIm23/3I401veLJkBuFLDT6yeKZNBx7Asskrkz0mUSQ==} engines: {node: '>=10'} cpu: [arm64] os: [linux] - '@swc/react-compiler-linux-arm64-musl@1.12.4': - resolution: {integrity: sha512-uD7qLqafic2Q4zw1a3bbxZBBCZ3m0xst2LJLXrzr0fcEDs7RdFmHhacHPNQwVNY3fsyep8HCLq9P1xOJx7Y49w==} + '@swc/react-compiler-linux-arm64-musl@1.12.7': + resolution: {integrity: sha512-DPUhc6q4V3dz5hzUXxWL5cFMP64rICCzM5PTq/LI1DBnYmHx5P3rvKbXsNwmVd2KRPAg5oApw+b53Y61cgdnFg==} engines: {node: '>=10'} cpu: [arm64] os: [linux] - '@swc/react-compiler-linux-x64-gnu@1.12.4': - resolution: {integrity: sha512-8SyWClpJivi1LUZFawYEWqMATlW/Rd6M3dTVh3Cir4kwiAIjC5WhaoYGz9+N7itK+/Fhb44B2Soqd4wVgylb1Q==} + '@swc/react-compiler-linux-x64-gnu@1.12.7': + resolution: {integrity: sha512-fU4Gwdvz5azdDxfiOuhTWf7xlHCzTDjEvN6Wg9tlMPLe2tQBgLtYPV8XR27ImTOUGhcmoIgJPffzNbBquFUi4g==} engines: {node: '>=10'} cpu: [x64] os: [linux] - '@swc/react-compiler-linux-x64-musl@1.12.4': - resolution: {integrity: sha512-ixz+vQPOkhWRnHEfelrAqoiJggwEjzsJi8KNxr8vcx+pG63TEN+QMM3vhC7UFkuiuKSDzzh0A1yPBki0b9gTlA==} + '@swc/react-compiler-linux-x64-musl@1.12.7': + resolution: {integrity: sha512-TWsHuJaqQmdpFKG1T7AWJJ+EnpUNK69b6ulQ/QtbB0HNhc1JixHDmn4gCvJ6XO3u3xlQfuu7drzZEecx58yUuA==} engines: {node: '>=10'} cpu: [x64] os: [linux] - '@swc/react-compiler-win32-arm64-msvc@1.12.4': - resolution: {integrity: sha512-h28OhDfjC4CeRYLv27+vgiloZj4ACFRf3vm1v2hfcRfdD8vmYgxis2KXMd27JIoSTbXIzVlxf97FT26U2Q6bHw==} + '@swc/react-compiler-win32-arm64-msvc@1.12.7': + resolution: {integrity: sha512-6ZU6e2a1VTD2pIxTu6nT8zCGW44QGmC6qh/GFoiZ+VmADM7S0xWYJiuj+ZRDi1zvdXCrVmxDQk7QFNp4WWMM3g==} engines: {node: '>=10'} cpu: [arm64] os: [win32] - '@swc/react-compiler-win32-ia32-msvc@1.12.4': - resolution: {integrity: sha512-U0BzBLMWn95EnQWA/nqjZ5ZvqRPrjnAmuULmWXkZFX+oUNAfjjPyDyumDVqik7XVw/f/1LdGICZjw3S/A6vHUg==} + '@swc/react-compiler-win32-ia32-msvc@1.12.7': + resolution: {integrity: sha512-OVWg/BgNbcU93Cu0ZjugMVMQiKsBvi4ETzjYT/bJaWbEjNFFiraABa92+aqL9t1HyI6Nnfod1B52LAY/+9iNAQ==} engines: {node: '>=10'} cpu: [ia32] os: [win32] - '@swc/react-compiler-win32-x64-msvc@1.12.4': - resolution: {integrity: sha512-R/tYdzXYK4rMTpChkSfAnuMBBaUuuO4Morhf73u+ytOpicUahwP6STwlew5APjQ7pwAao//val/l8N/OO6v2Rw==} + '@swc/react-compiler-win32-x64-msvc@1.12.7': + resolution: {integrity: sha512-YUttYekHRGLEf4Y+83A1Q1Ur4jPPLKPaJmcwpmY/t8ZB9AzB2uRx+YntrQ9Wp3XY+QKxJtNpbH7wcDzi3Wlm9A==} engines: {node: '>=10'} cpu: [x64] os: [win32] - '@swc/react-compiler@1.12.4': - resolution: {integrity: sha512-BsYk4ulWO2c3aRU9qYaj6VjczJ/PrteplK6UaqGD9AtmtDszf+oQfAvFROQhko9y+CcSNfXYNyWDh92UY03Iww==} + '@swc/react-compiler@1.12.7': + resolution: {integrity: sha512-xhu1sWAHcDx02nKQD4bhg4QiT84kb2bve0u5QZNSs9adCs7Tx6UGu3LoNuh5wD0ksbcuWWH/Jsh3Vw8Of1r3kA==} engines: {node: '>=20'} '@swc/types@0.1.23': @@ -7656,6 +7656,9 @@ packages: babel-plugin-react-compiler@0.0.0-experimental-cd3852a-20241229: resolution: {integrity: sha512-6qZBK55M1qrGXVj1joqPjiNnaYd2tBTnHHjirvJaqdrfPPzgT0vFT/LpMJEtcg/V1uy8tm0lR8MaLJAWeiWA7w==} + babel-plugin-react-compiler@19.1.0-rc.2: + resolution: {integrity: sha512-kSNA//p5fMO6ypG8EkEVPIqAjwIXm5tMjfD1XRPL/sRjYSbJ6UsvORfaeolNWnZ9n310aM0xJP7peW26BuCVzA==} + babel-preset-current-node-syntax@1.0.1: resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==} peerDependencies: @@ -14591,7 +14594,7 @@ snapshots: '@babel/helper-annotate-as-pure@7.25.9': dependencies: - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 '@babel/helper-annotate-as-pure@7.27.1': dependencies: @@ -14712,14 +14715,14 @@ snapshots: '@babel/helper-member-expression-to-functions@7.25.9': dependencies: '@babel/traverse': 7.27.1 - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color '@babel/helper-member-expression-to-functions@7.27.1': dependencies: '@babel/traverse': 7.27.1 - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -14806,11 +14809,11 @@ snapshots: '@babel/helper-optimise-call-expression@7.25.9': dependencies: - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 '@babel/helper-optimise-call-expression@7.27.1': dependencies: - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 '@babel/helper-plugin-utils@7.26.5': {} @@ -14873,7 +14876,7 @@ snapshots: '@babel/helper-skip-transparent-expression-wrappers@7.25.9': dependencies: '@babel/traverse': 7.27.1 - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -14900,7 +14903,7 @@ snapshots: dependencies: '@babel/template': 7.27.1 '@babel/traverse': 7.27.1 - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 transitivePeerDependencies: - supports-color @@ -19193,51 +19196,51 @@ snapshots: dependencies: '@swc/counter': 0.1.3 - '@swc/react-compiler-darwin-arm64@1.12.4': + '@swc/react-compiler-darwin-arm64@1.12.7': optional: true - '@swc/react-compiler-darwin-x64@1.12.4': + '@swc/react-compiler-darwin-x64@1.12.7': optional: true - '@swc/react-compiler-linux-arm-gnueabihf@1.12.4': + '@swc/react-compiler-linux-arm-gnueabihf@1.12.7': optional: true - '@swc/react-compiler-linux-arm64-gnu@1.12.4': + '@swc/react-compiler-linux-arm64-gnu@1.12.7': optional: true - '@swc/react-compiler-linux-arm64-musl@1.12.4': + '@swc/react-compiler-linux-arm64-musl@1.12.7': optional: true - '@swc/react-compiler-linux-x64-gnu@1.12.4': + '@swc/react-compiler-linux-x64-gnu@1.12.7': optional: true - '@swc/react-compiler-linux-x64-musl@1.12.4': + '@swc/react-compiler-linux-x64-musl@1.12.7': optional: true - '@swc/react-compiler-win32-arm64-msvc@1.12.4': + '@swc/react-compiler-win32-arm64-msvc@1.12.7': optional: true - '@swc/react-compiler-win32-ia32-msvc@1.12.4': + '@swc/react-compiler-win32-ia32-msvc@1.12.7': optional: true - '@swc/react-compiler-win32-x64-msvc@1.12.4': + '@swc/react-compiler-win32-x64-msvc@1.12.7': optional: true - '@swc/react-compiler@1.12.4': + '@swc/react-compiler@1.12.7': dependencies: '@swc/counter': 0.1.3 '@swc/types': 0.1.23 optionalDependencies: - '@swc/react-compiler-darwin-arm64': 1.12.4 - '@swc/react-compiler-darwin-x64': 1.12.4 - '@swc/react-compiler-linux-arm-gnueabihf': 1.12.4 - '@swc/react-compiler-linux-arm64-gnu': 1.12.4 - '@swc/react-compiler-linux-arm64-musl': 1.12.4 - '@swc/react-compiler-linux-x64-gnu': 1.12.4 - '@swc/react-compiler-linux-x64-musl': 1.12.4 - '@swc/react-compiler-win32-arm64-msvc': 1.12.4 - '@swc/react-compiler-win32-ia32-msvc': 1.12.4 - '@swc/react-compiler-win32-x64-msvc': 1.12.4 + '@swc/react-compiler-darwin-arm64': 1.12.7 + '@swc/react-compiler-darwin-x64': 1.12.7 + '@swc/react-compiler-linux-arm-gnueabihf': 1.12.7 + '@swc/react-compiler-linux-arm64-gnu': 1.12.7 + '@swc/react-compiler-linux-arm64-musl': 1.12.7 + '@swc/react-compiler-linux-x64-gnu': 1.12.7 + '@swc/react-compiler-linux-x64-musl': 1.12.7 + '@swc/react-compiler-win32-arm64-msvc': 1.12.7 + '@swc/react-compiler-win32-ia32-msvc': 1.12.7 + '@swc/react-compiler-win32-x64-msvc': 1.12.7 '@swc/types@0.1.23': dependencies: @@ -20700,7 +20703,7 @@ snapshots: babel-plugin-jest-hoist@29.6.3: dependencies: '@babel/template': 7.27.1 - '@babel/types': 7.27.1 + '@babel/types': 7.27.6 '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.20.5 @@ -20782,6 +20785,10 @@ snapshots: dependencies: '@babel/types': 7.26.0 + babel-plugin-react-compiler@19.1.0-rc.2: + dependencies: + '@babel/types': 7.27.6 + babel-preset-current-node-syntax@1.0.1(@babel/core@7.27.4): dependencies: '@babel/core': 7.27.4 diff --git a/rspack/react-compiler-babel-ts/package.json b/rspack/react-compiler-babel-ts/package.json index a8276e59..b6b9fdf7 100644 --- a/rspack/react-compiler-babel-ts/package.json +++ b/rspack/react-compiler-babel-ts/package.json @@ -19,7 +19,7 @@ "@babel/plugin-syntax-typescript": "^7.27.1", "@rspack/cli": "1.3.15", "@rspack/core": "1.3.15", - "@swc/react-compiler": "1.12.4", + "@swc/react-compiler": "1.12.7", "@types/react": "^19.1.8", "@types/react-dom": "^19.1.6", "babel-loader": "^10.0.0", diff --git a/rspack/react-compiler-babel-ts/rspack.config.js b/rspack/react-compiler-babel-ts/rspack.config.js index d5cabb45..e469016f 100644 --- a/rspack/react-compiler-babel-ts/rspack.config.js +++ b/rspack/react-compiler-babel-ts/rspack.config.js @@ -22,7 +22,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'typescript', @@ -33,18 +33,13 @@ const config = { }, ], }, - { - test: (resouce) => - /\.(jsx|tsx)$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), - loader: 'babel-loader', - }, { test: /\.(jsx|tsx)$/, use: [ { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'typescript', @@ -61,6 +56,11 @@ const config = { }, ], }, + { + test: (resouce) => + /\.(jsx|tsx)$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + loader: 'babel-loader', + }, { test: /\.(png|svg|jpg)$/, type: 'asset/resource', diff --git a/rspack/react-compiler-babel/package.json b/rspack/react-compiler-babel/package.json index 7919c027..7cb6fda5 100644 --- a/rspack/react-compiler-babel/package.json +++ b/rspack/react-compiler-babel/package.json @@ -18,7 +18,7 @@ "@babel/plugin-syntax-jsx": "^7.27.1", "@rspack/cli": "1.3.15", "@rspack/core": "1.3.15", - "@swc/react-compiler": "1.12.4", + "@swc/react-compiler": "1.12.7", "babel-loader": "^10.0.0", "babel-plugin-react-compiler": "0.0.0-experimental-cd3852a-20241229" } diff --git a/rspack/react-compiler-babel/rspack.config.js b/rspack/react-compiler-babel/rspack.config.js index 269eed45..b6e70f1f 100644 --- a/rspack/react-compiler-babel/rspack.config.js +++ b/rspack/react-compiler-babel/rspack.config.js @@ -22,7 +22,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'ecmascript', @@ -33,18 +33,13 @@ const config = { }, ], }, - { - test: (resouce) => - /\.jsx$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), - loader: 'babel-loader', - }, { test: /\.jsx$/, use: [ { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'ecmascript', @@ -59,11 +54,13 @@ const config = { }, }, }, - { - loader: 'babel-loader', - }, ], }, + { + test: (resouce) => + /\.jsx$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + loader: 'babel-loader', + }, { test: /\.(png|svg|jpg)$/, type: 'asset/resource', From fb13e5cabe910451e2ec05532aaf271d1584e813 Mon Sep 17 00:00:00 2001 From: qixuan <58852732+GiveMe-A-Name@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:57:58 +0800 Subject: [PATCH 3/4] Update rspack/react-compiler-babel/rspack.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rspack/react-compiler-babel/rspack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rspack/react-compiler-babel/rspack.config.js b/rspack/react-compiler-babel/rspack.config.js index b6e70f1f..898910a3 100644 --- a/rspack/react-compiler-babel/rspack.config.js +++ b/rspack/react-compiler-babel/rspack.config.js @@ -57,8 +57,8 @@ const config = { ], }, { - test: (resouce) => - /\.jsx$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + test: (resource) => + /\.jsx$/.test(resource) && isReactCompilerRequiredSync(fs.readFileSync(resource)), loader: 'babel-loader', }, { From bb157d5cf7f42f10f225ab58274d3fd90b2f1c79 Mon Sep 17 00:00:00 2001 From: qixuan <58852732+GiveMe-A-Name@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:58:04 +0800 Subject: [PATCH 4/4] Update rspack/react-compiler-babel-ts/rspack.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rspack/react-compiler-babel-ts/rspack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rspack/react-compiler-babel-ts/rspack.config.js b/rspack/react-compiler-babel-ts/rspack.config.js index e469016f..8b074f4e 100644 --- a/rspack/react-compiler-babel-ts/rspack.config.js +++ b/rspack/react-compiler-babel-ts/rspack.config.js @@ -57,8 +57,8 @@ const config = { ], }, { - test: (resouce) => - /\.(jsx|tsx)$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)), + test: (resource) => + /\.(jsx|tsx)$/.test(resource) && isReactCompilerRequiredSync(fs.readFileSync(resource)), loader: 'babel-loader', }, {