diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa795e53..1742889c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2164,12 +2164,15 @@ importers: '@rspack/core': specifier: 1.3.15 version: 1.3.15(@swc/helpers@0.5.17) + '@swc/react-compiler': + 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: @@ -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.7 + version: 1.12.7 '@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.7': + resolution: {integrity: sha512-/YTWN0kPTVEZ1Q9VcZMYc4NtYGds3/OMnPa/FF7c5P92qtclTFCXgZifdBZN5D6S62LRwvisev/2yJ2VmZcJmA==} + engines: {node: '>=10'} + cpu: [arm64] + os: [darwin] + + '@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.7': + resolution: {integrity: sha512-beBAWmt4I8oPKA3Lm4DchbeI97imNXIUtSkmJxuy86M4kVTYHgkFWwjHedn2Adx1sJF/Q9RMmWHvgmpGt6wb+g==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@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.7': + resolution: {integrity: sha512-DPUhc6q4V3dz5hzUXxWL5cFMP64rICCzM5PTq/LI1DBnYmHx5P3rvKbXsNwmVd2KRPAg5oApw+b53Y61cgdnFg==} + engines: {node: '>=10'} + cpu: [arm64] + os: [linux] + + '@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.7': + resolution: {integrity: sha512-TWsHuJaqQmdpFKG1T7AWJJ+EnpUNK69b6ulQ/QtbB0HNhc1JixHDmn4gCvJ6XO3u3xlQfuu7drzZEecx58yUuA==} + engines: {node: '>=10'} + cpu: [x64] + os: [linux] + + '@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.7': + resolution: {integrity: sha512-OVWg/BgNbcU93Cu0ZjugMVMQiKsBvi4ETzjYT/bJaWbEjNFFiraABa92+aqL9t1HyI6Nnfod1B52LAY/+9iNAQ==} + engines: {node: '>=10'} + cpu: [ia32] + os: [win32] + + '@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.7': + resolution: {integrity: sha512-xhu1sWAHcDx02nKQD4bhg4QiT84kb2bve0u5QZNSs9adCs7Tx6UGu3LoNuh5wD0ksbcuWWH/Jsh3Vw8Of1r3kA==} + engines: {node: '>=20'} + '@swc/types@0.1.23': resolution: {integrity: sha512-u1iIVZV9Q0jxY+yM2vw/hZGDNudsN85bBpTqzAQ9rzkxW9D+e3aEM4Han+ow518gSewkXgjmEK0BD79ZcNVgPw==} @@ -7586,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: @@ -14521,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: @@ -14642,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 @@ -14736,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': {} @@ -14803,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 @@ -14830,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 @@ -19123,6 +19196,52 @@ snapshots: dependencies: '@swc/counter': 0.1.3 + '@swc/react-compiler-darwin-arm64@1.12.7': + optional: true + + '@swc/react-compiler-darwin-x64@1.12.7': + optional: true + + '@swc/react-compiler-linux-arm-gnueabihf@1.12.7': + optional: true + + '@swc/react-compiler-linux-arm64-gnu@1.12.7': + optional: true + + '@swc/react-compiler-linux-arm64-musl@1.12.7': + optional: true + + '@swc/react-compiler-linux-x64-gnu@1.12.7': + optional: true + + '@swc/react-compiler-linux-x64-musl@1.12.7': + optional: true + + '@swc/react-compiler-win32-arm64-msvc@1.12.7': + optional: true + + '@swc/react-compiler-win32-ia32-msvc@1.12.7': + optional: true + + '@swc/react-compiler-win32-x64-msvc@1.12.7': + optional: true + + '@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.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: '@swc/counter': 0.1.3 @@ -20584,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 @@ -20666,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 4bf0af5b..b6b9fdf7 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.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 197c9a94..8b074f4e 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: { @@ -19,7 +22,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'typescript', @@ -36,7 +39,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'typescript', @@ -51,11 +54,13 @@ const config = { }, }, }, - { - loader: 'babel-loader', - }, ], }, + { + test: (resource) => + /\.(jsx|tsx)$/.test(resource) && isReactCompilerRequiredSync(fs.readFileSync(resource)), + 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 1c990bc6..7cb6fda5 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.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 46ddd0dd..898910a3 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: { @@ -19,7 +22,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'ecmascript', @@ -36,7 +39,7 @@ const config = { { loader: 'builtin:swc-loader', options: { - sourceMap: true, + sourceMaps: true, jsc: { parser: { syntax: 'ecmascript', @@ -51,11 +54,13 @@ const config = { }, }, }, - { - loader: 'babel-loader', - }, ], }, + { + test: (resource) => + /\.jsx$/.test(resource) && isReactCompilerRequiredSync(fs.readFileSync(resource)), + loader: 'babel-loader', + }, { test: /\.(png|svg|jpg)$/, type: 'asset/resource',