From 24c9baba04711b3afb5fbdda0e3e6fdb7dbd4057 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Nov 2026 17:54:46 +0800 Subject: [PATCH 1/3] feat: migrate Solid examples to Solid 2 --- pnpm-lock.yaml | 422 ++++++++++++-------- rsbuild/solid/README.md | 6 +- rsbuild/solid/package.json | 7 +- rsbuild/solid/rsbuild.config.ts | 9 +- rslib/solid-basic/README.md | 2 + rslib/solid-basic/package.json | 9 +- rslib/solid-basic/rslib.config.ts | 8 +- rslib/solid-basic/tsconfig.json | 2 +- rslib/solid-rstest/README.md | 4 + rslib/solid-rstest/package.json | 11 +- rslib/solid-rstest/rslib.config.ts | 8 +- rslib/solid-rstest/tsconfig.json | 2 +- rspack/solid/README.md | 16 + rspack/solid/package.json | 11 +- rspack/solid/rspack.config.js | 19 +- rspack/solid/solid-loader.js | 41 ++ rspack/solid/src/index.jsx | 3 +- rstest/rsbuild-solid/README.md | 14 + rstest/rsbuild-solid/package.json | 8 +- rstest/rsbuild-solid/rsbuild.config.ts | 9 +- rstest/rsbuild-solid/rstest.config.ts | 1 + rstest/rsbuild-solid/src/index.tsx | 2 +- rstest/rsbuild-solid/tests/adapter.test.tsx | 2 +- rstest/rsbuild-solid/tests/counter.test.tsx | 5 +- rstest/rsbuild-solid/tsconfig.json | 2 +- 25 files changed, 389 insertions(+), 234 deletions(-) create mode 100644 rspack/solid/README.md create mode 100644 rspack/solid/solid-loader.js create mode 100644 rstest/rsbuild-solid/README.md diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0905b7016..4530cce7c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,6 @@ settings: excludeLinksFromLockfile: false importers: - .: devDependencies: cross-env: @@ -531,21 +530,18 @@ importers: rsbuild/solid: dependencies: '@solidjs/web': - specifier: ^2.0.0-rc.13 - version: 2.0.0-rc.14(solid-js@2.0.0-rc.14) + specifier: ^2.0.0 + version: 2.0.0(solid-js@2.0.0) solid-js: - specifier: ^2.0.0-rc.13 - version: 2.0.0-rc.14 + specifier: ^2.0.0 + version: 2.0.0 devDependencies: '@rsbuild/core': specifier: 2.2.12 version: 2.2.12(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0) - '@rsbuild/plugin-babel': - specifier: ^2.1.0 - version: 2.1.0(@rsbuild/core@2.2.12)(@rspack/core@2.2.8)(webpack@5.102.1) '@rsbuild/plugin-solid': - specifier: ^2.0.0-rc.1 - version: 2.0.0-rc.1(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0-rc.14)(solid-js@2.0.0-rc.14) + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0)(solid-js@2.0.0) '@types/node': specifier: ^24.19.2 version: 24.19.2 @@ -1731,30 +1727,27 @@ importers: rslib/solid-basic: devDependencies: - '@rsbuild/plugin-babel': - specifier: ^2.1.0 - version: 2.1.0(@rsbuild/core@2.2.12)(@rspack/core@2.2.8)(webpack@5.102.1) '@rsbuild/plugin-solid': - specifier: ^1.2.2 - version: 1.2.2(@babel/core@7.29.7)(@rsbuild/core@2.2.12)(solid-js@1.9.17) + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0)(solid-js@2.0.0) '@rslib/core': specifier: ^1.0.3 version: 1.0.3(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0)(typescript@5.9.3) + '@solidjs/web': + specifier: ^2.0.0 + version: 2.0.0(solid-js@2.0.0) solid-js: - specifier: ^1.9.17 - version: 1.9.17 + specifier: ^2.0.0 + version: 2.0.0 typescript: specifier: ^5.9.3 version: 5.9.3 rslib/solid-rstest: devDependencies: - '@rsbuild/plugin-babel': - specifier: ^2.1.0 - version: 2.1.0(@rsbuild/core@2.2.12)(@rspack/core@2.2.8)(webpack@5.102.1) '@rsbuild/plugin-solid': - specifier: ^1.2.2 - version: 1.2.2(@babel/core@7.29.7)(@rsbuild/core@2.2.12)(solid-js@1.9.17) + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0)(solid-js@2.0.0) '@rslib/core': specifier: ^1.0.3 version: 1.0.3(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0)(typescript@5.9.3) @@ -1765,14 +1758,17 @@ importers: specifier: ^0.12.3 version: 0.12.3(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0)(happy-dom@21.0.4)(jsdom@30.1.2) '@solidjs/testing-library': - specifier: ^0.8.10 - version: 0.8.10(solid-js@1.9.17) + specifier: 1.0.0-rc.2 + version: 1.0.0-rc.2(@solidjs/web@2.0.0)(solid-js@2.0.0) + '@solidjs/web': + specifier: ^2.0.0 + version: 2.0.0(solid-js@2.0.0) happy-dom: specifier: ^21.0.0 version: 21.0.4 solid-js: - specifier: ^1.9.17 - version: 1.9.17 + specifier: ^2.0.0 + version: 2.0.0 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -3545,22 +3541,16 @@ importers: rspack/solid: dependencies: - '@babel/core': - specifier: 7.29.7 - version: 7.29.7 - babel-loader: - specifier: 10.1.1 - version: 10.1.1(@babel/core@7.29.7)(@rspack/core@2.2.8)(webpack@5.102.1) - babel-preset-solid: - specifier: 1.9.16 - version: 1.9.16(@babel/core@7.29.7)(solid-js@1.9.17) + '@solidjs/web': + specifier: ^2.0.0 + version: 2.0.0(solid-js@2.0.0) solid-js: - specifier: 1.9.17 - version: 1.9.17 - solid-refresh: - specifier: 0.7.8 - version: 0.7.8(solid-js@1.9.17) + specifier: ^2.0.0 + version: 2.0.0 devDependencies: + '@jridgewell/remapping': + specifier: ^2.3.5 + version: 2.3.5 '@rspack/cli': specifier: 2.2.8 version: 2.2.8(@rspack/core@2.2.8)(@rspack/dev-server@2.2.1) @@ -3570,6 +3560,9 @@ importers: '@rspack/dev-server': specifier: 2.2.1 version: 2.2.1(@rspack/core@2.2.8)(selfsigned@5.5.0) + '@solidjs/compiler': + specifier: 2.0.0 + version: 2.0.0 rspack/source-map-with-vscode-debugging: dependencies: @@ -4530,27 +4523,27 @@ importers: '@rsbuild/core': specifier: 2.2.12 version: 2.2.12(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0) - '@rsbuild/plugin-babel': - specifier: ^2.1.0 - version: 2.1.0(@rsbuild/core@2.2.12)(@rspack/core@2.2.8)(webpack@5.102.1) '@rsbuild/plugin-solid': - specifier: ^1.2.2 - version: 1.2.2(@babel/core@7.29.7)(@rsbuild/core@2.2.12)(solid-js@1.9.17) + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0)(solid-js@2.0.0) '@rstest/adapter-rsbuild': specifier: ^0.12.3 version: 0.12.3(@rsbuild/core@2.2.12)(@rstest/core@0.12.3) '@rstest/core': specifier: ^0.12.3 - version: 0.12.3(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0)(happy-dom@21.0.4)(jsdom@30.1.2) + version: 0.12.3(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0)(happy-dom@20.14.6)(jsdom@30.1.2) + '@solidjs/web': + specifier: ^2.0.0 + version: 2.0.0(solid-js@2.0.0) '@types/node': specifier: ^24.19.2 version: 24.19.2 - happy-dom: - specifier: ^21.0.0 - version: 21.0.4 + jsdom: + specifier: ^30.1.2 + version: 30.1.2(@noble/hashes@1.8.0) solid-js: - specifier: ^1.9.17 - version: 1.9.17 + specifier: ^2.0.0 + version: 2.0.0 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -4661,8 +4654,8 @@ importers: specifier: ^5.9.3 version: 5.9.3 -packages: +packages: '@aashutoshrathi/word-wrap@1.2.6': resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} engines: {node: '>=0.10.0'} @@ -4764,10 +4757,18 @@ packages: resolution: {integrity: sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==} engines: {node: '>=6.9.0'} + '@babel/core@7.29.13': + resolution: {integrity: sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==} + engines: {node: '>=6.9.0'} + '@babel/core@7.29.7': resolution: {integrity: sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==} engines: {node: '>=6.9.0'} + '@babel/generator@7.29.14': + resolution: {integrity: sha512-qSY56jgW5JnSXzuekLVil6zaOQxOCtOHidr65KkaMBw772IuAY28Qx4ZykAcDn8+FRF15qk80XzKwgSc/RYW6g==} + engines: {node: '>=6.9.0'} + '@babel/generator@7.29.7': resolution: {integrity: sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==} engines: {node: '>=6.9.0'} @@ -4780,6 +4781,10 @@ packages: resolution: {integrity: sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==} engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.29.13': + resolution: {integrity: sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==} + engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.29.7': resolution: {integrity: sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==} engines: {node: '>=6.9.0'} @@ -4817,6 +4822,12 @@ packages: resolution: {integrity: sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==} engines: {node: '>=6.9.0'} + '@babel/helper-module-transforms@7.29.14': + resolution: {integrity: sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-module-transforms@7.29.7': resolution: {integrity: sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==} engines: {node: '>=6.9.0'} @@ -4851,6 +4862,10 @@ packages: resolution: {integrity: sha512-fWegr+WsEsiMVW4KUNdIIzzMTZSzNiqhy0//6+2MRi2d5NFNsL/AYwBQW8eBnRbTBVRnDVzjaJEUqKaCWjMMdQ==} engines: {node: '>=6.9.0'} + '@babel/helper-string-parser@7.29.14': + resolution: {integrity: sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-string-parser@7.29.7': resolution: {integrity: sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==} engines: {node: '>=6.9.0'} @@ -4867,10 +4882,19 @@ packages: resolution: {integrity: sha512-iES0Skag9ERIF68aXadpO6dbXa03mNWK3sEqJaMnLNs/eC3l0lkImdfoy6Y09/SfkpawdAB4RjQ7PVA7TcVGdw==} engines: {node: '>=6.9.0'} + '@babel/helpers@7.29.14': + resolution: {integrity: sha512-6E3Mi1r0B0umq6vmZa4/78q+64fqO2YY0THUdjDPKUCKhNb0yQy5NQIaPHCSD3ryTgiTss//P4JsWS80AsZ6LQ==} + engines: {node: '>=6.9.0'} + '@babel/helpers@7.29.7': resolution: {integrity: sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==} engines: {node: '>=6.9.0'} + '@babel/parser@7.29.14': + resolution: {integrity: sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/parser@7.29.7': resolution: {integrity: sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==} engines: {node: '>=6.0.0'} @@ -5362,6 +5386,10 @@ packages: resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==} engines: {node: '>=6.9.0'} + '@babel/traverse@7.29.14': + resolution: {integrity: sha512-RAdQJrBgmIH1FWvN0X+1hoDxzMzlP4cv/1Zi4dn4tG1H0cTb+rw7CzUxQJhp1f4ANd8j5vH3fy8BAWFGkBDEsA==} + engines: {node: '>=6.9.0'} + '@babel/traverse@7.29.7': resolution: {integrity: sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==} engines: {node: '>=6.9.0'} @@ -5374,6 +5402,10 @@ packages: resolution: {integrity: sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==} engines: {node: '>=6.9.0'} + '@babel/types@7.29.14': + resolution: {integrity: sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==} + engines: {node: '>=6.9.0'} + '@babel/types@7.29.7': resolution: {integrity: sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==} engines: {node: '>=6.9.0'} @@ -7807,12 +7839,12 @@ packages: '@rsbuild/core': optional: true - '@rsbuild/plugin-solid@2.0.0-rc.1': - resolution: {integrity: sha512-J4zFwj1n8XHY/E0+dqedhjKVa6cwaRDThEn951/kXX6XFuT5RR+4E7X8ltrmBQsB0Eb5qzfPmuhIdcKoPg0Zfw==} + '@rsbuild/plugin-solid@2.0.0': + resolution: {integrity: sha512-X1QPB4Fi8WQpvY87xHRlQJXsgPO+cb2SYOBb0gDA3B6QoxpADrlz+daOtJZ9eySlpzQyb0uoNjmBy5UAUOR3Iw==} peerDependencies: '@rsbuild/core': ^2.0.0 - '@solidjs/web': ^2.0.0-rc.6 - solid-js: ^2.0.0-rc.6 + '@solidjs/web': ^2.0.0 + solid-js: ^2.0.0 peerDependenciesMeta: '@rsbuild/core': optional: true @@ -8582,73 +8614,70 @@ packages: peerDependencies: solid-js: ^1.6.12 - '@solidjs/babel-plugin@2.0.0-rc.13': - resolution: {integrity: sha512-VaNysg2V5gu1leatjxBeRPvj1wTEB1LQ1bKuPABKBGztz/Vjr6bHUYEV2cC1mFuEyNJBaNrAiGv0+5Vpbl8Pug==} + '@solidjs/babel-plugin@2.0.0': + resolution: {integrity: sha512-ucX1GQofDDbu+S7d12h3H2lUARagSleaY/GQ+2sG2EthAMkqBXeX92hhkHVJPK+KtiJeCXQxdzfvKhFCzudirQ==} peerDependencies: - '@babel/core': ^7.20.12 + '@babel/core': ^7.20.12 || ^8.0.0 '@tsrx/core': 0.1.63 peerDependenciesMeta: '@tsrx/core': optional: true - '@solidjs/compiler-darwin-arm64@2.0.0-rc.13': - resolution: {integrity: sha512-uG3Sa/2jNZNxoKkcHjHw3KZEEuwDrRAk9aqUU2qqJZl9GDLLI0HVW7i/Lvq9b17f5yN+fNTdNyojO8rLgHnQuQ==} + '@solidjs/compiler-darwin-arm64@2.0.0': + resolution: {integrity: sha512-pPHERRXgCcsfCsaC8sgK94uVlp4WGUcHTfMeBiAfme2amQ7vFn7dpjSD3TIVKY4jeYQTKjIKOYP0c5mqIR1LeA==} cpu: [arm64] os: [darwin] - '@solidjs/compiler-darwin-x64@2.0.0-rc.13': - resolution: {integrity: sha512-jIyzyn/fYHmzikOaskiqmkc8FusXMaxl1Z6huh7lEeHaZsl9NIdzzAIxq8j/EJFByvoCyfQitggRTuubGNblpA==} + '@solidjs/compiler-darwin-x64@2.0.0': + resolution: {integrity: sha512-Ndwy+pQs8v6BIfaAbQ+weu9HGBTM40HFCyu0XV2qX7U5XC+o+3fc4O6+8ZZyUzl+qvT6XU+wh2bQ6MI2lV+KBQ==} cpu: [x64] os: [darwin] - '@solidjs/compiler-linux-arm64-gnu@2.0.0-rc.13': - resolution: {integrity: sha512-cGIX7ZWTyw3Qdpd5ZqJtHdb2vQkAtZlkTgy919dMldjoRqDwQIRlqCmH35kaH/IUBlhuG224BoP4twqK9GYyGw==} + '@solidjs/compiler-linux-arm64-gnu@2.0.0': + resolution: {integrity: sha512-H/R9SUmuqd4P/IuuXTlRM1LhgUWe2EjLP3iMUo+L4IO1rmOSqfMUZp9h52eQnDsOdoIZCaKsw+b0qC5WooxDlg==} cpu: [arm64] os: [linux] libc: [glibc] - '@solidjs/compiler-linux-x64-gnu@2.0.0-rc.13': - resolution: {integrity: sha512-Dnft4iic4zHsemNSBGMwOMjN4fP0DEoyfeSUWbqBk1CMsXRarLTcMKhjNQmJvL0opzjOUq0/m7/17LTe6AKpvg==} + '@solidjs/compiler-linux-x64-gnu@2.0.0': + resolution: {integrity: sha512-gafr9+2bP2sv2hRAvDgzab0mpQi4MiyWrie9bfYjadsK7qZKJBeMzEQCLNd4dTYlgirCj6Frzu2pfET7+ZUyNQ==} cpu: [x64] os: [linux] libc: [glibc] - '@solidjs/compiler-wasm32-wasi@2.0.0-rc.13': - resolution: {integrity: sha512-nNOMOFxanzfM2wNbSXyekMtGazyOcM3ja+P7tk0NJYTAo2MYmRTY/HUDdFRDluk6Nc5aehu87I7AVMRj5l1WXw==} + '@solidjs/compiler-wasm32-wasi@2.0.0': + resolution: {integrity: sha512-JnF21DJ/jx5fghYKIB6ANihHMM4aWg4JFe5pFLGDvqSeURZJdJGjwyyxOv3siEMUdkBzVGHXotTsviTcRyB5hQ==} engines: {node: '>=14.0.0'} - '@solidjs/compiler-win32-x64-msvc@2.0.0-rc.13': - resolution: {integrity: sha512-1DT+5TgIFV5L8GdrGb+uD9ruHFVq6kJ4A/cb9amUU574TGM88B4nwy//dM57zmT99u7mej7JF91glQBnHOGhHQ==} + '@solidjs/compiler-win32-x64-msvc@2.0.0': + resolution: {integrity: sha512-RkiUXt/LmJ1lk1fECa/iDVGCOv3UiwW5ocZgkhpayUviTSrceFjFHhiM9sFXq0at3kHI7Z8awN6zTaF5IStDAQ==} cpu: [x64] os: [win32] - '@solidjs/compiler@2.0.0-rc.13': - resolution: {integrity: sha512-OveR/xhLKo8MTJO/53jgjHuBW54c6/a9B/jiSjDrBeQ3JSbODUxQ8t58WBSlHaxyowPd27TwhVkLo3zeT1YqMQ==} + '@solidjs/compiler@2.0.0': + resolution: {integrity: sha512-Spgqz1+eojQ2pDl4yajnajIjX/kSusjTK/6mC6Fm7sAZ3YBI0yP4/epRR1hV08TU3YAH4xLBmZ6wjb1zC134Sw==} '@solidjs/meta@0.29.4': resolution: {integrity: sha512-zdIWBGpR9zGx1p1bzIPqF5Gs+Ks/BH8R6fWhmUa/dcK1L2rUC8BAcZJzNRYBQv74kScf1TSOs0EY//Vd/I0V8g==} peerDependencies: solid-js: '>=1.8.4' - '@solidjs/signals@2.0.0-rc.14': - resolution: {integrity: sha512-s3v1wpPcX3wfNO0WUERrPrXS+qqJ4ylzH9QTIRKqrgcMVeLEOXgFa3hZrhEoVTp+lVAgido2NH6GCI79twe2fg==} + '@solidjs/signals@2.0.0': + resolution: {integrity: sha512-jrcT6XTVvsYRpesRp0At/mSUnsWr6jiprK8C93Oat56B8n7X9BMSe58Rxl6qSZUhBN0L+sxm8GzeO7HdhBXvDw==} engines: {node: '>=22.12.0'} - '@solidjs/testing-library@0.8.10': - resolution: {integrity: sha512-qdeuIerwyq7oQTIrrKvV0aL9aFeuwTd86VYD3afdq5HYEwoox1OBTJy4y8A3TFZr8oAR0nujYgCzY/8wgHGfeQ==} + '@solidjs/testing-library@1.0.0-rc.2': + resolution: {integrity: sha512-QZqIVoyDAqaGgSsWQ3gnYGaG1peFkNF0/n5uM+393g5plZlcvgxmUgdjsQtwrRLVZCrh0K1lp7YHxsAlN5XPkA==} engines: {node: '>= 14'} peerDependencies: - '@solidjs/router': '>=0.9.0' - solid-js: '>=1.0.0' - peerDependenciesMeta: - '@solidjs/router': - optional: true + '@solidjs/web': '>=2.0.0-0' + solid-js: '>=2.0.0-0' - '@solidjs/web@2.0.0-rc.14': - resolution: {integrity: sha512-MhHqUoVBdgAG7EZOANx7Y5SuCFH7sBxzt9uBSYLpJxE503tqoi7pX1UhV7PWxw4LvmPe1PZkdkSOZ8BLchZkhQ==} + '@solidjs/web@2.0.0': + resolution: {integrity: sha512-R0+JMCD6ukEXaID/sH5PVQe9bCIN9pRzJry+F6Sb6YvtlkAp9DEyVI7AeZYiV0cd6TSL98kpbCyLDiZnaAKGrA==} engines: {node: '>=22.12.0'} peerDependencies: - solid-js: ^2.0.0-rc.14 + solid-js: ^2.0.0 '@standard-schema/spec@1.1.0': resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} @@ -10120,11 +10149,6 @@ packages: webpack: optional: true - babel-plugin-jsx-dom-expressions@0.40.11: - resolution: {integrity: sha512-k7TkOv7uVYnrq/bYyVvG5cWOC9IObAGfmyW3aMkG8l2sq2qt/5THkUBja69PMLEGGi8G+fXB2Fh7eS4OwZRBoQ==} - peerDependencies: - '@babel/core': ^7.20.12 - babel-plugin-jsx-dom-expressions@0.40.6: resolution: {integrity: sha512-v3P1MW46Lm7VMpAkq0QfyzLWWkC8fh+0aE5Km4msIgDx5kjenHU0pF2s+4/NH8CQn/kla6+Hvws+2AF7bfV5qQ==} peerDependencies: @@ -10161,15 +10185,6 @@ packages: solid-js: optional: true - babel-preset-solid@1.9.16: - resolution: {integrity: sha512-+0h40Qk2oBfkQ4OGDBHIDtvq/XQiOnCfzjNHmMxriAr8MmdsaIbyJgqYglDs4d70sF8O08sSpx61TKdpUt3oRw==} - peerDependencies: - '@babel/core': ^7.0.0 - solid-js: ^1.9.16 - peerDependenciesMeta: - solid-js: - optional: true - babel-walk@3.0.0-canary-5: resolution: {integrity: sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==} engines: {node: '>= 10.0.0'} @@ -15210,10 +15225,20 @@ packages: peerDependencies: seroval: ^1.0 + seroval-plugins@1.8.0: + resolution: {integrity: sha512-96vBb12rDvPPwdKUgWw1op3fGq8AVBFOr0IllbnM72yR5J9WWXF18cQ4g1XfDO7HCyh2dt70P3XdtyRayP8FWg==} + engines: {node: '>=20'} + peerDependencies: + seroval: ^1.8.0 + seroval@1.6.9: resolution: {integrity: sha512-UeEzHwAK+yl0YLbsvROV1t5yMYEwZZ0CfKYxDvUgS2fO9Vxdf8djqVIB+OuVpuawRNPqw68LE1Du/GMsW2ZPqA==} engines: {node: '>=10'} + seroval@1.8.2: + resolution: {integrity: sha512-zmMxi/9MdLK1MKazLmIP6Rk39RuK0Xydd+QHeOYntS37olJeTjB3+nwVj4ce/ZWiZJeRhcO5htfxt0mUzQBscQ==} + engines: {node: '>=20'} + serve-handler@6.1.7: resolution: {integrity: sha512-CinAq1xWb0vR3twAv9evEU8cNWkXCb9kd5ePAHUKJBkOsUpR1wt/CvGdeca7vqumL1U5cSaeVQ6zZMxiJ3yWsg==} @@ -15352,8 +15377,8 @@ packages: solid-js@1.9.17: resolution: {integrity: sha512-4GAmLOWPfNV8H9Jfn2LSFTpNEG6jiOKPiwd5lnLGQtehHaX6l3TOLzJqQ7mqwB/3k1Yy3zyumFVopmc/tm34ow==} - solid-js@2.0.0-rc.14: - resolution: {integrity: sha512-fmaqUHgbITf18Hedur6gPnaPE4GrdPgkTbLujHqM5Vl5jxWf9rxwFh6hZMXQs+Kg1pu8KYuOMfqnuSizFQ9I6Q==} + solid-js@2.0.0: + resolution: {integrity: sha512-9zN4uH2OQeQAYbF4BmIzoaa+L5Hb8Dp6kkP6ZXobHQ1FZVICdmzREPDVDBJY7umzdAE8D6zbFfWhxGtagkyslA==} engines: {node: '>=22.12.0'} solid-refresh@0.6.3: @@ -15361,11 +15386,6 @@ packages: peerDependencies: solid-js: ^1.3 - solid-refresh@0.7.8: - resolution: {integrity: sha512-iG442T3HXJp5jEebCy8okETrWnmX7CnxNOKrJQVeufh6WXSn+xtLXaptUXXMHTWcRqTJOJwQ8UwzxrRtVFSIzA==} - peerDependencies: - solid-js: ^1.3 - sonic-boom@4.2.1: resolution: {integrity: sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==} @@ -16903,8 +16923,8 @@ packages: zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} -snapshots: +snapshots: '@aashutoshrathi/word-wrap@1.2.6': {} '@adobe/css-tools@4.3.3': {} @@ -16988,6 +17008,26 @@ snapshots: '@babel/compat-data@7.29.7': {} + '@babel/core@7.29.13': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.14 + '@babel/helper-compilation-targets': 7.29.13 + '@babel/helper-module-transforms': 7.29.14(@babel/core@7.29.13) + '@babel/helpers': 7.29.14 + '@babel/parser': 7.29.14 + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.14 + '@babel/types': 7.29.11 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.3 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.2 + transitivePeerDependencies: + - supports-color + '@babel/core@7.29.7': dependencies: '@babel/code-frame': 7.29.7 @@ -17008,6 +17048,14 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/generator@7.29.14': + dependencies: + '@babel/parser': 7.29.14 + '@babel/types': 7.29.14 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + jsesc: 3.1.0 + '@babel/generator@7.29.7': dependencies: '@babel/parser': 7.29.7 @@ -17028,6 +17076,14 @@ snapshots: dependencies: '@babel/types': 7.29.7 + '@babel/helper-compilation-targets@7.29.13': + dependencies: + '@babel/compat-data': 7.29.7 + '@babel/helper-validator-option': 7.29.7 + browserslist: 4.29.5 + lru-cache: 5.1.1 + semver: 6.3.2 + '@babel/helper-compilation-targets@7.29.7': dependencies: '@babel/compat-data': 7.29.7 @@ -17087,6 +17143,15 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-module-transforms@7.29.14(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13 + '@babel/helper-module-imports': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 + '@babel/traverse': 7.29.14 + transitivePeerDependencies: + - supports-color + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 @@ -17130,6 +17195,8 @@ snapshots: '@babel/helper-string-parser@7.29.13': optional: true + '@babel/helper-string-parser@7.29.14': {} + '@babel/helper-string-parser@7.29.7': {} '@babel/helper-validator-identifier@7.29.7': {} @@ -17144,11 +17211,20 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helpers@7.29.14': + dependencies: + '@babel/template': 7.29.7 + '@babel/types': 7.29.14 + '@babel/helpers@7.29.7': dependencies: '@babel/template': 7.29.7 '@babel/types': 7.29.7 + '@babel/parser@7.29.14': + dependencies: + '@babel/types': 7.29.14 + '@babel/parser@7.29.7': dependencies: '@babel/types': 7.29.7 @@ -17233,6 +17309,11 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13 + '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 @@ -17764,6 +17845,18 @@ snapshots: '@babel/parser': 7.29.7 '@babel/types': 7.29.7 + '@babel/traverse@7.29.14': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.14 + '@babel/helper-globals': 7.29.7 + '@babel/parser': 7.29.14 + '@babel/template': 7.29.7 + '@babel/types': 7.29.14 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + '@babel/traverse@7.29.7': dependencies: '@babel/code-frame': 7.29.7 @@ -17794,6 +17887,11 @@ snapshots: '@babel/helper-validator-identifier': 7.29.7 optional: true + '@babel/types@7.29.14': + dependencies: + '@babel/helper-string-parser': 7.29.14 + '@babel/helper-validator-identifier': 7.29.7 + '@babel/types@7.29.7': dependencies: '@babel/helper-string-parser': 7.29.7 @@ -19175,6 +19273,13 @@ snapshots: '@tybys/wasm-util': 0.10.4 optional: true + '@napi-rs/wasm-runtime@1.2.7(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': + dependencies: + '@emnapi/core': 1.11.3 + '@emnapi/runtime': 1.11.3 + '@tybys/wasm-util': 0.10.4 + optional: true + '@neodrag/core@3.0.0-next.11': {} '@neodrag/solid@3.0.0-next.11(@neodrag/core@3.0.0-next.11)(solid-js@1.9.17)': @@ -20024,14 +20129,14 @@ snapshots: - solid-js - supports-color - '@rsbuild/plugin-solid@2.0.0-rc.1(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0-rc.14)(solid-js@2.0.0-rc.14)': + '@rsbuild/plugin-solid@2.0.0(@rsbuild/core@2.2.12)(@solidjs/web@2.0.0)(solid-js@2.0.0)': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.13 '@jridgewell/remapping': 2.3.5 - '@solidjs/babel-plugin': 2.0.0-rc.13(@babel/core@7.29.7) - '@solidjs/compiler': 2.0.0-rc.13 - '@solidjs/web': 2.0.0-rc.14(solid-js@2.0.0-rc.14) - solid-js: 2.0.0-rc.14 + '@solidjs/babel-plugin': 2.0.0(@babel/core@7.29.13) + '@solidjs/compiler': 2.0.0 + '@solidjs/web': 2.0.0(solid-js@2.0.0) + solid-js: 2.0.0 optionalDependencies: '@rsbuild/core': 2.2.12(@module-federation/runtime-tools@2.9.2)(core-js@3.50.0) transitivePeerDependencies: @@ -20878,62 +20983,64 @@ snapshots: dependencies: solid-js: 1.9.17 - '@solidjs/babel-plugin@2.0.0-rc.13(@babel/core@7.29.7)': + '@solidjs/babel-plugin@2.0.0(@babel/core@7.29.13)': dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.13 '@babel/helper-module-imports': 7.18.6 - '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7) - '@babel/types': 7.29.8 + '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.13) + '@babel/types': 7.29.11 html-entities: 2.3.3 parse5: 7.3.0 - '@solidjs/compiler-darwin-arm64@2.0.0-rc.13': + '@solidjs/compiler-darwin-arm64@2.0.0': optional: true - '@solidjs/compiler-darwin-x64@2.0.0-rc.13': + '@solidjs/compiler-darwin-x64@2.0.0': optional: true - '@solidjs/compiler-linux-arm64-gnu@2.0.0-rc.13': + '@solidjs/compiler-linux-arm64-gnu@2.0.0': optional: true - '@solidjs/compiler-linux-x64-gnu@2.0.0-rc.13': + '@solidjs/compiler-linux-x64-gnu@2.0.0': optional: true - '@solidjs/compiler-wasm32-wasi@2.0.0-rc.13': + '@solidjs/compiler-wasm32-wasi@2.0.0': dependencies: '@emnapi/core': 1.11.3 '@emnapi/runtime': 1.11.3 - '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) + '@napi-rs/wasm-runtime': 1.2.7(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) optional: true - '@solidjs/compiler-win32-x64-msvc@2.0.0-rc.13': + '@solidjs/compiler-win32-x64-msvc@2.0.0': optional: true - '@solidjs/compiler@2.0.0-rc.13': + '@solidjs/compiler@2.0.0': optionalDependencies: - '@solidjs/compiler-darwin-arm64': 2.0.0-rc.13 - '@solidjs/compiler-darwin-x64': 2.0.0-rc.13 - '@solidjs/compiler-linux-arm64-gnu': 2.0.0-rc.13 - '@solidjs/compiler-linux-x64-gnu': 2.0.0-rc.13 - '@solidjs/compiler-wasm32-wasi': 2.0.0-rc.13 - '@solidjs/compiler-win32-x64-msvc': 2.0.0-rc.13 + '@solidjs/compiler-darwin-arm64': 2.0.0 + '@solidjs/compiler-darwin-x64': 2.0.0 + '@solidjs/compiler-linux-arm64-gnu': 2.0.0 + '@solidjs/compiler-linux-x64-gnu': 2.0.0 + '@solidjs/compiler-wasm32-wasi': 2.0.0 + '@solidjs/compiler-win32-x64-msvc': 2.0.0 '@solidjs/meta@0.29.4(solid-js@1.9.17)': dependencies: solid-js: 1.9.17 - '@solidjs/signals@2.0.0-rc.14': {} + '@solidjs/signals@2.0.0': {} - '@solidjs/testing-library@0.8.10(solid-js@1.9.17)': + '@solidjs/testing-library@1.0.0-rc.2(@solidjs/web@2.0.0)(solid-js@2.0.0)': dependencies: - '@testing-library/dom': 10.4.1 - solid-js: 1.9.17 + '@solidjs/web': 2.0.0(solid-js@2.0.0) + '@testing-library/dom': 10.4.2 + solid-js: 2.0.0 - '@solidjs/web@2.0.0-rc.14(solid-js@2.0.0-rc.14)': + '@solidjs/web@2.0.0(solid-js@2.0.0)': dependencies: - seroval: 1.6.9 - seroval-plugins: 1.6.9(seroval@1.6.9) - solid-js: 2.0.0-rc.14 + csstype: 3.2.3 + seroval: 1.8.2 + seroval-plugins: 1.8.0(seroval@1.8.2) + solid-js: 2.0.0 '@standard-schema/spec@1.1.0': {} @@ -22783,15 +22890,6 @@ snapshots: '@rspack/core': 2.2.8(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.23) webpack: 5.102.1(postcss@8.5.29) - babel-plugin-jsx-dom-expressions@0.40.11(@babel/core@7.29.7): - dependencies: - '@babel/core': 7.29.7 - '@babel/helper-module-imports': 7.18.6 - '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7) - '@babel/types': 7.29.8 - html-entities: 2.3.3 - parse5: 7.3.0 - babel-plugin-jsx-dom-expressions@0.40.6(@babel/core@7.29.7): dependencies: '@babel/core': 7.29.7 @@ -22843,13 +22941,6 @@ snapshots: optionalDependencies: solid-js: 1.9.17 - babel-preset-solid@1.9.16(@babel/core@7.29.7)(solid-js@1.9.17): - dependencies: - '@babel/core': 7.29.7 - babel-plugin-jsx-dom-expressions: 0.40.11(@babel/core@7.29.7) - optionalDependencies: - solid-js: 1.9.17 - babel-walk@3.0.0-canary-5: dependencies: '@babel/types': 7.29.8 @@ -29071,8 +29162,14 @@ snapshots: dependencies: seroval: 1.6.9 + seroval-plugins@1.8.0(seroval@1.8.2): + dependencies: + seroval: 1.8.2 + seroval@1.6.9: {} + seroval@1.8.2: {} + serve-handler@6.1.7: dependencies: bytes: 3.0.0 @@ -29322,12 +29419,11 @@ snapshots: seroval: 1.6.9 seroval-plugins: 1.6.9(seroval@1.6.9) - solid-js@2.0.0-rc.14: + solid-js@2.0.0: dependencies: - '@solidjs/signals': 2.0.0-rc.14 - csstype: 3.2.3 - seroval: 1.6.9 - seroval-plugins: 1.6.9(seroval@1.6.9) + '@solidjs/signals': 2.0.0 + seroval: 1.8.2 + seroval-plugins: 1.8.0(seroval@1.8.2) solid-refresh@0.6.3(solid-js@1.9.17): dependencies: @@ -29338,12 +29434,6 @@ snapshots: transitivePeerDependencies: - supports-color - solid-refresh@0.7.8(solid-js@1.9.17): - dependencies: - '@babel/generator': 7.29.7 - '@babel/types': 7.29.7 - solid-js: 1.9.17 - sonic-boom@4.2.1: dependencies: atomic-sleep: 1.0.0 diff --git a/rsbuild/solid/README.md b/rsbuild/solid/README.md index 37b1dd332..9df7a010f 100644 --- a/rsbuild/solid/README.md +++ b/rsbuild/solid/README.md @@ -1,4 +1,8 @@ -# Rsbuild Project +# Rsbuild with Solid 2 + +Use `@rsbuild/plugin-solid` v2 with `solid-js` and `@solidjs/web` v2. The default native compiler handles JSX and Solid Refresh without a Babel plugin. + +Import DOM APIs such as `render` from `@solidjs/web`, and set TypeScript's `jsx` to `preserve` and `jsxImportSource` to `@solidjs/web`. ## Setup diff --git a/rsbuild/solid/package.json b/rsbuild/solid/package.json index 1b71e7a74..81a75691e 100644 --- a/rsbuild/solid/package.json +++ b/rsbuild/solid/package.json @@ -9,13 +9,12 @@ "preview": "rsbuild preview" }, "dependencies": { - "@solidjs/web": "^2.0.0-rc.13", - "solid-js": "^2.0.0-rc.13" + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0" }, "devDependencies": { "@rsbuild/core": "2.2.12", - "@rsbuild/plugin-babel": "^2.1.0", - "@rsbuild/plugin-solid": "^2.0.0-rc.1", + "@rsbuild/plugin-solid": "^2.0.0", "@types/node": "^24.19.2", "typescript": "^5.9.3" } diff --git a/rsbuild/solid/rsbuild.config.ts b/rsbuild/solid/rsbuild.config.ts index b294ebdb6..1c71fe269 100644 --- a/rsbuild/solid/rsbuild.config.ts +++ b/rsbuild/solid/rsbuild.config.ts @@ -1,13 +1,6 @@ import { defineConfig } from '@rsbuild/core'; -import { pluginBabel } from '@rsbuild/plugin-babel'; import { pluginSolid } from '@rsbuild/plugin-solid'; export default defineConfig({ - plugins: [ - pluginBabel({ - include: /\.(?:jsx|tsx)$/, - exclude: /[\\/]node_modules[\\/]/, - }), - pluginSolid(), - ], + plugins: [pluginSolid()], }); diff --git a/rslib/solid-basic/README.md b/rslib/solid-basic/README.md index ace8557f5..b4d01f584 100644 --- a/rslib/solid-basic/README.md +++ b/rslib/solid-basic/README.md @@ -1,5 +1,7 @@ # Rslib Solid basic +This example targets Solid 2. `@rsbuild/plugin-solid` v2 compiles the JavaScript output without Babel, while the `solid` export condition preserves JSX for consumers to compile. Both `solid-js` and `@solidjs/web` are peer dependencies. + ## Setup Install the dependencies: diff --git a/rslib/solid-basic/package.json b/rslib/solid-basic/package.json index 7c3925588..dd712ef45 100644 --- a/rslib/solid-basic/package.json +++ b/rslib/solid-basic/package.json @@ -18,13 +18,14 @@ "dev": "rslib -w" }, "devDependencies": { - "@rsbuild/plugin-babel": "^2.1.0", - "@rsbuild/plugin-solid": "^1.2.2", + "@rsbuild/plugin-solid": "^2.0.0", "@rslib/core": "^1.0.3", - "solid-js": "^1.9.17", + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0", "typescript": "^5.9.3" }, "peerDependencies": { - "solid-js": "^1.8.0" + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0" } } diff --git a/rslib/solid-basic/rslib.config.ts b/rslib/solid-basic/rslib.config.ts index d5e3def94..c37aba23e 100644 --- a/rslib/solid-basic/rslib.config.ts +++ b/rslib/solid-basic/rslib.config.ts @@ -1,4 +1,3 @@ -import { pluginBabel } from '@rsbuild/plugin-babel'; import { pluginSolid } from '@rsbuild/plugin-solid'; import { defineConfig } from '@rslib/core'; @@ -8,12 +7,7 @@ export default defineConfig({ { id: 'compiled', dts: true, - plugins: [ - pluginBabel({ - include: /\.(?:jsx|tsx)$/, - }), - pluginSolid(), - ], + plugins: [pluginSolid()], }, { id: 'source', diff --git a/rslib/solid-basic/tsconfig.json b/rslib/solid-basic/tsconfig.json index 57d4c149b..58df6ce80 100644 --- a/rslib/solid-basic/tsconfig.json +++ b/rslib/solid-basic/tsconfig.json @@ -3,7 +3,7 @@ "lib": ["DOM", "ES2022"], "module": "ESNext", "jsx": "preserve", - "jsxImportSource": "solid-js", + "jsxImportSource": "@solidjs/web", "strict": true, "skipLibCheck": true, "types": ["@rslib/core/types"], diff --git a/rslib/solid-rstest/README.md b/rslib/solid-rstest/README.md index beacabf1d..12ed2f876 100644 --- a/rslib/solid-rstest/README.md +++ b/rslib/solid-rstest/README.md @@ -1,5 +1,9 @@ # Rslib Solid Rstest +This example targets Solid 2. `@rsbuild/plugin-solid` v2 compiles the JavaScript output without Babel, while the `solid` export condition preserves JSX for consumers to compile. Both `solid-js` and `@solidjs/web` are peer dependencies. + +`@solidjs/testing-library` is pinned to `1.0.0-rc.2` for Solid 2 support. + ## Setup Install the dependencies: diff --git a/rslib/solid-rstest/package.json b/rslib/solid-rstest/package.json index 415de631e..36f80834d 100644 --- a/rslib/solid-rstest/package.json +++ b/rslib/solid-rstest/package.json @@ -19,17 +19,18 @@ "test": "rstest" }, "devDependencies": { - "@rsbuild/plugin-babel": "^2.1.0", - "@rsbuild/plugin-solid": "^1.2.2", + "@rsbuild/plugin-solid": "^2.0.0", "@rslib/core": "^1.0.3", "@rstest/adapter-rslib": "^0.12.3", "@rstest/core": "^0.12.3", - "@solidjs/testing-library": "^0.8.10", + "@solidjs/testing-library": "1.0.0-rc.2", + "@solidjs/web": "^2.0.0", "happy-dom": "^21.0.0", - "solid-js": "^1.9.17", + "solid-js": "^2.0.0", "typescript": "^5.9.3" }, "peerDependencies": { - "solid-js": "^1.8.0" + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0" } } diff --git a/rslib/solid-rstest/rslib.config.ts b/rslib/solid-rstest/rslib.config.ts index d5e3def94..c37aba23e 100644 --- a/rslib/solid-rstest/rslib.config.ts +++ b/rslib/solid-rstest/rslib.config.ts @@ -1,4 +1,3 @@ -import { pluginBabel } from '@rsbuild/plugin-babel'; import { pluginSolid } from '@rsbuild/plugin-solid'; import { defineConfig } from '@rslib/core'; @@ -8,12 +7,7 @@ export default defineConfig({ { id: 'compiled', dts: true, - plugins: [ - pluginBabel({ - include: /\.(?:jsx|tsx)$/, - }), - pluginSolid(), - ], + plugins: [pluginSolid()], }, { id: 'source', diff --git a/rslib/solid-rstest/tsconfig.json b/rslib/solid-rstest/tsconfig.json index 57d4c149b..58df6ce80 100644 --- a/rslib/solid-rstest/tsconfig.json +++ b/rslib/solid-rstest/tsconfig.json @@ -3,7 +3,7 @@ "lib": ["DOM", "ES2022"], "module": "ESNext", "jsx": "preserve", - "jsxImportSource": "solid-js", + "jsxImportSource": "@solidjs/web", "strict": true, "skipLibCheck": true, "types": ["@rslib/core/types"], diff --git a/rspack/solid/README.md b/rspack/solid/README.md new file mode 100644 index 000000000..cd2a105d2 --- /dev/null +++ b/rspack/solid/README.md @@ -0,0 +1,16 @@ +# Rspack with Solid 2 + +For an integrated setup, use [Rsbuild's Solid plugin](https://rsbuild.rs/plugins/list/plugin-solid). This example shows how to configure Rspack directly with Solid 2's native compiler. + +- `solid-loader.js` runs `@solidjs/compiler` and enables `solid-js/refresh` for application code in development. `builtin:swc-loader` then handles JavaScript syntax lowering. +- The `solid` resolve condition selects JSX sources from Solid libraries. +- Dynamic imports inside `@solidjs/web` are left for the runtime, which loads hydration modules from URLs. +- DOM APIs such as `render` come from `@solidjs/web`. + +```bash +pnpm install +pnpm dev +pnpm build +``` + +Increment the counter, then edit `src/Message.jsx`. Solid Refresh updates the child component while preserving the parent's count. diff --git a/rspack/solid/package.json b/rspack/solid/package.json index c7730f7be..8aff9d6d3 100644 --- a/rspack/solid/package.json +++ b/rspack/solid/package.json @@ -9,15 +9,14 @@ "dev": "rspack dev" }, "dependencies": { - "@babel/core": "7.29.7", - "babel-loader": "10.1.1", - "babel-preset-solid": "1.9.16", - "solid-js": "1.9.17", - "solid-refresh": "0.7.8" + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0" }, "devDependencies": { + "@jridgewell/remapping": "^2.3.5", "@rspack/cli": "2.2.8", "@rspack/core": "2.2.8", - "@rspack/dev-server": "2.2.1" + "@rspack/dev-server": "2.2.1", + "@solidjs/compiler": "2.0.0" } } diff --git a/rspack/solid/rspack.config.js b/rspack/solid/rspack.config.js index 9d15526e6..e1dacc0eb 100644 --- a/rspack/solid/rspack.config.js +++ b/rspack/solid/rspack.config.js @@ -1,6 +1,7 @@ // @ts-check import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; +import { fileURLToPath } from 'node:url'; export default defineConfig({ context: import.meta.dirname, @@ -8,10 +9,16 @@ export default defineConfig({ main: './src/index.jsx', }, resolve: { + conditionNames: ['solid', '...'], extensions: ['...', '.ts', '.tsx', '.jsx'], }, module: { rules: [ + { + // Solid loads hydration modules from runtime URLs. + descriptionData: { name: /^@solidjs\/web$/ }, + parser: { importDynamic: false }, + }, { test: /\.[cm]?[jt]sx?$/, resolve: { @@ -34,14 +41,14 @@ export default defineConfig({ type: 'asset/resource', }, { - test: /\.jsx$/, + test: /\.[jt]sx$/, use: [ { - loader: 'babel-loader', - options: { - presets: [['solid']], - plugins: ['solid-refresh/babel'], - }, + loader: 'builtin:swc-loader', + options: { detectSyntax: 'auto' }, + }, + { + loader: fileURLToPath(new URL('./solid-loader.js', import.meta.url)), }, ], }, diff --git a/rspack/solid/solid-loader.js b/rspack/solid/solid-loader.js new file mode 100644 index 000000000..d6b8ed1a3 --- /dev/null +++ b/rspack/solid/solid-loader.js @@ -0,0 +1,41 @@ +import { transformAsync, transformRefreshAsync } from '@solidjs/compiler'; +import remapping from '@jridgewell/remapping'; + +/** @type {import('@rspack/core').LoaderDefinition} */ +export default async function solidLoader(source, inputSourceMap) { + const callback = this.async(); + const filename = this.resourcePath; + const dev = this.mode === 'development'; + + try { + let code = source; + const maps = []; + + // Register component boundaries before compiling JSX. Only app code needs HMR. + if (dev && this.hot && !/[\\/]node_modules[\\/]/.test(filename)) { + const refresh = await transformRefreshAsync(code, { + filename, + bundler: 'standard', + importSource: 'solid-js/refresh', + sourceMap: true, + }); + code = refresh.code; + if (refresh.map) maps.push(JSON.parse(refresh.map)); + } + + const result = await transformAsync(code, { + filename, + generate: 'dom', + dev, + sourceMap: true, + }); + if (result.map) maps.unshift(JSON.parse(result.map)); + if (inputSourceMap) { + maps.push(typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap); + } + + callback(null, result.code, maps.length ? remapping(maps, () => null) : undefined); + } catch (error) { + callback(error instanceof Error ? error : new Error(String(error))); + } +} diff --git a/rspack/solid/src/index.jsx b/rspack/solid/src/index.jsx index 27c0e53ad..07412cb87 100644 --- a/rspack/solid/src/index.jsx +++ b/rspack/solid/src/index.jsx @@ -1,5 +1,4 @@ -/* @refresh reload */ -import { render } from 'solid-js/web'; +import { render } from '@solidjs/web'; import './index.css'; import App from './App'; diff --git a/rstest/rsbuild-solid/README.md b/rstest/rsbuild-solid/README.md new file mode 100644 index 000000000..cc3a89bb0 --- /dev/null +++ b/rstest/rsbuild-solid/README.md @@ -0,0 +1,14 @@ +# Rstest with Rsbuild and Solid 2 + +`withRsbuildConfig()` reuses `@rsbuild/plugin-solid` v2, aliases, and defines from the Rsbuild configuration. No Babel plugin is needed. + +The tests use jsdom. happy-dom 21.0.4 does not create a text node when `textContent` is set to the number `0`, which breaks subsequent Solid 2 text updates. + +Import `render` from `@solidjs/web` and call `flush()` from `solid-js` after interactions to apply batched reactive updates before asserting DOM changes. + +```bash +pnpm install +pnpm build +pnpm test +pnpm dev +``` diff --git a/rstest/rsbuild-solid/package.json b/rstest/rsbuild-solid/package.json index f96670909..34b8cc454 100644 --- a/rstest/rsbuild-solid/package.json +++ b/rstest/rsbuild-solid/package.json @@ -11,13 +11,13 @@ }, "devDependencies": { "@rsbuild/core": "2.2.12", - "@rsbuild/plugin-babel": "^2.1.0", - "@rsbuild/plugin-solid": "^1.2.2", + "@rsbuild/plugin-solid": "^2.0.0", "@rstest/adapter-rsbuild": "^0.12.3", "@rstest/core": "^0.12.3", + "@solidjs/web": "^2.0.0", "@types/node": "^24.19.2", - "happy-dom": "^21.0.0", - "solid-js": "^1.9.17", + "jsdom": "^30.1.2", + "solid-js": "^2.0.0", "typescript": "^5.9.3" } } diff --git a/rstest/rsbuild-solid/rsbuild.config.ts b/rstest/rsbuild-solid/rsbuild.config.ts index 280f9280e..8e767df45 100644 --- a/rstest/rsbuild-solid/rsbuild.config.ts +++ b/rstest/rsbuild-solid/rsbuild.config.ts @@ -1,16 +1,9 @@ import path from 'node:path'; import { defineConfig } from '@rsbuild/core'; -import { pluginBabel } from '@rsbuild/plugin-babel'; import { pluginSolid } from '@rsbuild/plugin-solid'; export default defineConfig({ - plugins: [ - pluginBabel({ - include: /\.(?:jsx|tsx)$/, - exclude: /[\\/]node_modules[\\/]/, - }), - pluginSolid(), - ], + plugins: [pluginSolid()], source: { entry: { index: './src/index.tsx', diff --git a/rstest/rsbuild-solid/rstest.config.ts b/rstest/rsbuild-solid/rstest.config.ts index 299909423..1528ab34e 100644 --- a/rstest/rsbuild-solid/rstest.config.ts +++ b/rstest/rsbuild-solid/rstest.config.ts @@ -3,4 +3,5 @@ import { defineConfig } from '@rstest/core'; export default defineConfig({ extends: withRsbuildConfig(), + testEnvironment: 'jsdom', }); diff --git a/rstest/rsbuild-solid/src/index.tsx b/rstest/rsbuild-solid/src/index.tsx index 0adcc684e..ced50cb0c 100644 --- a/rstest/rsbuild-solid/src/index.tsx +++ b/rstest/rsbuild-solid/src/index.tsx @@ -1,4 +1,4 @@ -import { render } from 'solid-js/web'; +import { render } from '@solidjs/web'; import { Counter } from './components/Counter'; const root = diff --git a/rstest/rsbuild-solid/tests/adapter.test.tsx b/rstest/rsbuild-solid/tests/adapter.test.tsx index 1bf7e7270..02ab3e810 100644 --- a/rstest/rsbuild-solid/tests/adapter.test.tsx +++ b/rstest/rsbuild-solid/tests/adapter.test.tsx @@ -1,6 +1,6 @@ import { Counter } from '@components/Counter'; import { afterEach, beforeEach, describe, expect, it } from '@rstest/core'; -import { render } from 'solid-js/web'; +import { render } from '@solidjs/web'; declare const __APP_VERSION__: string; diff --git a/rstest/rsbuild-solid/tests/counter.test.tsx b/rstest/rsbuild-solid/tests/counter.test.tsx index 7af2cf5c7..647d0fb68 100644 --- a/rstest/rsbuild-solid/tests/counter.test.tsx +++ b/rstest/rsbuild-solid/tests/counter.test.tsx @@ -1,5 +1,6 @@ import { afterEach, beforeEach, describe, expect, it } from '@rstest/core'; -import { render } from 'solid-js/web'; +import { render } from '@solidjs/web'; +import { flush } from 'solid-js'; import { Counter } from '../src/components/Counter'; describe('pluginSolid - component rendering', () => { @@ -30,6 +31,8 @@ describe('pluginSolid - component rendering', () => { '[data-testid="increment-btn"]', ) as HTMLButtonElement; incrementButton.click(); + // Solid 2 batches reactive updates. Flush before asserting DOM changes. + flush(); expect(container.querySelector('[data-testid="counter-value"]')?.textContent).toBe('1'); }); diff --git a/rstest/rsbuild-solid/tsconfig.json b/rstest/rsbuild-solid/tsconfig.json index 78c4a2370..251cf3316 100644 --- a/rstest/rsbuild-solid/tsconfig.json +++ b/rstest/rsbuild-solid/tsconfig.json @@ -7,7 +7,7 @@ "esModuleInterop": true, "skipLibCheck": true, "jsx": "preserve", - "jsxImportSource": "solid-js", + "jsxImportSource": "@solidjs/web", "types": ["@rsbuild/core/types", "node", "@rstest/core"], "paths": { "@/*": ["./src/*"], From bbbd4074f1f75f9ca59f11c51066425123ce29e5 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Nov 2026 17:58:13 +0800 Subject: [PATCH 2/3] docs: remove extra Solid example README changes --- rsbuild/solid/README.md | 6 +----- rslib/solid-basic/README.md | 2 -- rslib/solid-rstest/README.md | 4 ---- rspack/solid/README.md | 16 ---------------- rstest/rsbuild-solid/README.md | 14 -------------- 5 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 rspack/solid/README.md delete mode 100644 rstest/rsbuild-solid/README.md diff --git a/rsbuild/solid/README.md b/rsbuild/solid/README.md index 9df7a010f..37b1dd332 100644 --- a/rsbuild/solid/README.md +++ b/rsbuild/solid/README.md @@ -1,8 +1,4 @@ -# Rsbuild with Solid 2 - -Use `@rsbuild/plugin-solid` v2 with `solid-js` and `@solidjs/web` v2. The default native compiler handles JSX and Solid Refresh without a Babel plugin. - -Import DOM APIs such as `render` from `@solidjs/web`, and set TypeScript's `jsx` to `preserve` and `jsxImportSource` to `@solidjs/web`. +# Rsbuild Project ## Setup diff --git a/rslib/solid-basic/README.md b/rslib/solid-basic/README.md index b4d01f584..ace8557f5 100644 --- a/rslib/solid-basic/README.md +++ b/rslib/solid-basic/README.md @@ -1,7 +1,5 @@ # Rslib Solid basic -This example targets Solid 2. `@rsbuild/plugin-solid` v2 compiles the JavaScript output without Babel, while the `solid` export condition preserves JSX for consumers to compile. Both `solid-js` and `@solidjs/web` are peer dependencies. - ## Setup Install the dependencies: diff --git a/rslib/solid-rstest/README.md b/rslib/solid-rstest/README.md index 12ed2f876..beacabf1d 100644 --- a/rslib/solid-rstest/README.md +++ b/rslib/solid-rstest/README.md @@ -1,9 +1,5 @@ # Rslib Solid Rstest -This example targets Solid 2. `@rsbuild/plugin-solid` v2 compiles the JavaScript output without Babel, while the `solid` export condition preserves JSX for consumers to compile. Both `solid-js` and `@solidjs/web` are peer dependencies. - -`@solidjs/testing-library` is pinned to `1.0.0-rc.2` for Solid 2 support. - ## Setup Install the dependencies: diff --git a/rspack/solid/README.md b/rspack/solid/README.md deleted file mode 100644 index cd2a105d2..000000000 --- a/rspack/solid/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Rspack with Solid 2 - -For an integrated setup, use [Rsbuild's Solid plugin](https://rsbuild.rs/plugins/list/plugin-solid). This example shows how to configure Rspack directly with Solid 2's native compiler. - -- `solid-loader.js` runs `@solidjs/compiler` and enables `solid-js/refresh` for application code in development. `builtin:swc-loader` then handles JavaScript syntax lowering. -- The `solid` resolve condition selects JSX sources from Solid libraries. -- Dynamic imports inside `@solidjs/web` are left for the runtime, which loads hydration modules from URLs. -- DOM APIs such as `render` come from `@solidjs/web`. - -```bash -pnpm install -pnpm dev -pnpm build -``` - -Increment the counter, then edit `src/Message.jsx`. Solid Refresh updates the child component while preserving the parent's count. diff --git a/rstest/rsbuild-solid/README.md b/rstest/rsbuild-solid/README.md deleted file mode 100644 index cc3a89bb0..000000000 --- a/rstest/rsbuild-solid/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Rstest with Rsbuild and Solid 2 - -`withRsbuildConfig()` reuses `@rsbuild/plugin-solid` v2, aliases, and defines from the Rsbuild configuration. No Babel plugin is needed. - -The tests use jsdom. happy-dom 21.0.4 does not create a text node when `textContent` is set to the number `0`, which breaks subsequent Solid 2 text updates. - -Import `render` from `@solidjs/web` and call `flush()` from `solid-js` after interactions to apply batched reactive updates before asserting DOM changes. - -```bash -pnpm install -pnpm build -pnpm test -pnpm dev -``` From 7ff861fcd78b03bddef6c1d0be6d5ffe82ed9222 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Nov 2026 18:37:33 +0800 Subject: [PATCH 3/3] chore: defer Rspack Solid example migration --- pnpm-lock.yaml | 66 +++++++++++++++++++++++++++++------ rspack/solid/package.json | 11 +++--- rspack/solid/rspack.config.js | 19 ++++------ rspack/solid/solid-loader.js | 41 ---------------------- rspack/solid/src/index.jsx | 3 +- 5 files changed, 69 insertions(+), 71 deletions(-) delete mode 100644 rspack/solid/solid-loader.js diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4530cce7c..00ee5de19 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3541,16 +3541,22 @@ importers: rspack/solid: dependencies: - '@solidjs/web': - specifier: ^2.0.0 - version: 2.0.0(solid-js@2.0.0) + '@babel/core': + specifier: 7.29.7 + version: 7.29.7 + babel-loader: + specifier: 10.1.1 + version: 10.1.1(@babel/core@7.29.7)(@rspack/core@2.2.8)(webpack@5.102.1) + babel-preset-solid: + specifier: 1.9.16 + version: 1.9.16(@babel/core@7.29.7)(solid-js@1.9.17) solid-js: - specifier: ^2.0.0 - version: 2.0.0 + specifier: 1.9.17 + version: 1.9.17 + solid-refresh: + specifier: 0.7.8 + version: 0.7.8(solid-js@1.9.17) devDependencies: - '@jridgewell/remapping': - specifier: ^2.3.5 - version: 2.3.5 '@rspack/cli': specifier: 2.2.8 version: 2.2.8(@rspack/core@2.2.8)(@rspack/dev-server@2.2.1) @@ -3560,9 +3566,6 @@ importers: '@rspack/dev-server': specifier: 2.2.1 version: 2.2.1(@rspack/core@2.2.8)(selfsigned@5.5.0) - '@solidjs/compiler': - specifier: 2.0.0 - version: 2.0.0 rspack/source-map-with-vscode-debugging: dependencies: @@ -10149,6 +10152,11 @@ packages: webpack: optional: true + babel-plugin-jsx-dom-expressions@0.40.11: + resolution: {integrity: sha512-k7TkOv7uVYnrq/bYyVvG5cWOC9IObAGfmyW3aMkG8l2sq2qt/5THkUBja69PMLEGGi8G+fXB2Fh7eS4OwZRBoQ==} + peerDependencies: + '@babel/core': ^7.20.12 + babel-plugin-jsx-dom-expressions@0.40.6: resolution: {integrity: sha512-v3P1MW46Lm7VMpAkq0QfyzLWWkC8fh+0aE5Km4msIgDx5kjenHU0pF2s+4/NH8CQn/kla6+Hvws+2AF7bfV5qQ==} peerDependencies: @@ -10185,6 +10193,15 @@ packages: solid-js: optional: true + babel-preset-solid@1.9.16: + resolution: {integrity: sha512-+0h40Qk2oBfkQ4OGDBHIDtvq/XQiOnCfzjNHmMxriAr8MmdsaIbyJgqYglDs4d70sF8O08sSpx61TKdpUt3oRw==} + peerDependencies: + '@babel/core': ^7.0.0 + solid-js: ^1.9.16 + peerDependenciesMeta: + solid-js: + optional: true + babel-walk@3.0.0-canary-5: resolution: {integrity: sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==} engines: {node: '>= 10.0.0'} @@ -15386,6 +15403,11 @@ packages: peerDependencies: solid-js: ^1.3 + solid-refresh@0.7.8: + resolution: {integrity: sha512-iG442T3HXJp5jEebCy8okETrWnmX7CnxNOKrJQVeufh6WXSn+xtLXaptUXXMHTWcRqTJOJwQ8UwzxrRtVFSIzA==} + peerDependencies: + solid-js: ^1.3 + sonic-boom@4.2.1: resolution: {integrity: sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==} @@ -22890,6 +22912,15 @@ snapshots: '@rspack/core': 2.2.8(@module-federation/runtime-tools@2.9.2)(@swc/helpers@0.5.23) webpack: 5.102.1(postcss@8.5.29) + babel-plugin-jsx-dom-expressions@0.40.11(@babel/core@7.29.7): + dependencies: + '@babel/core': 7.29.7 + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7) + '@babel/types': 7.29.8 + html-entities: 2.3.3 + parse5: 7.3.0 + babel-plugin-jsx-dom-expressions@0.40.6(@babel/core@7.29.7): dependencies: '@babel/core': 7.29.7 @@ -22941,6 +22972,13 @@ snapshots: optionalDependencies: solid-js: 1.9.17 + babel-preset-solid@1.9.16(@babel/core@7.29.7)(solid-js@1.9.17): + dependencies: + '@babel/core': 7.29.7 + babel-plugin-jsx-dom-expressions: 0.40.11(@babel/core@7.29.7) + optionalDependencies: + solid-js: 1.9.17 + babel-walk@3.0.0-canary-5: dependencies: '@babel/types': 7.29.8 @@ -29434,6 +29472,12 @@ snapshots: transitivePeerDependencies: - supports-color + solid-refresh@0.7.8(solid-js@1.9.17): + dependencies: + '@babel/generator': 7.29.7 + '@babel/types': 7.29.7 + solid-js: 1.9.17 + sonic-boom@4.2.1: dependencies: atomic-sleep: 1.0.0 diff --git a/rspack/solid/package.json b/rspack/solid/package.json index 8aff9d6d3..c7730f7be 100644 --- a/rspack/solid/package.json +++ b/rspack/solid/package.json @@ -9,14 +9,15 @@ "dev": "rspack dev" }, "dependencies": { - "@solidjs/web": "^2.0.0", - "solid-js": "^2.0.0" + "@babel/core": "7.29.7", + "babel-loader": "10.1.1", + "babel-preset-solid": "1.9.16", + "solid-js": "1.9.17", + "solid-refresh": "0.7.8" }, "devDependencies": { - "@jridgewell/remapping": "^2.3.5", "@rspack/cli": "2.2.8", "@rspack/core": "2.2.8", - "@rspack/dev-server": "2.2.1", - "@solidjs/compiler": "2.0.0" + "@rspack/dev-server": "2.2.1" } } diff --git a/rspack/solid/rspack.config.js b/rspack/solid/rspack.config.js index e1dacc0eb..9d15526e6 100644 --- a/rspack/solid/rspack.config.js +++ b/rspack/solid/rspack.config.js @@ -1,7 +1,6 @@ // @ts-check import { defineConfig } from '@rspack/cli'; import { rspack } from '@rspack/core'; -import { fileURLToPath } from 'node:url'; export default defineConfig({ context: import.meta.dirname, @@ -9,16 +8,10 @@ export default defineConfig({ main: './src/index.jsx', }, resolve: { - conditionNames: ['solid', '...'], extensions: ['...', '.ts', '.tsx', '.jsx'], }, module: { rules: [ - { - // Solid loads hydration modules from runtime URLs. - descriptionData: { name: /^@solidjs\/web$/ }, - parser: { importDynamic: false }, - }, { test: /\.[cm]?[jt]sx?$/, resolve: { @@ -41,14 +34,14 @@ export default defineConfig({ type: 'asset/resource', }, { - test: /\.[jt]sx$/, + test: /\.jsx$/, use: [ { - loader: 'builtin:swc-loader', - options: { detectSyntax: 'auto' }, - }, - { - loader: fileURLToPath(new URL('./solid-loader.js', import.meta.url)), + loader: 'babel-loader', + options: { + presets: [['solid']], + plugins: ['solid-refresh/babel'], + }, }, ], }, diff --git a/rspack/solid/solid-loader.js b/rspack/solid/solid-loader.js deleted file mode 100644 index d6b8ed1a3..000000000 --- a/rspack/solid/solid-loader.js +++ /dev/null @@ -1,41 +0,0 @@ -import { transformAsync, transformRefreshAsync } from '@solidjs/compiler'; -import remapping from '@jridgewell/remapping'; - -/** @type {import('@rspack/core').LoaderDefinition} */ -export default async function solidLoader(source, inputSourceMap) { - const callback = this.async(); - const filename = this.resourcePath; - const dev = this.mode === 'development'; - - try { - let code = source; - const maps = []; - - // Register component boundaries before compiling JSX. Only app code needs HMR. - if (dev && this.hot && !/[\\/]node_modules[\\/]/.test(filename)) { - const refresh = await transformRefreshAsync(code, { - filename, - bundler: 'standard', - importSource: 'solid-js/refresh', - sourceMap: true, - }); - code = refresh.code; - if (refresh.map) maps.push(JSON.parse(refresh.map)); - } - - const result = await transformAsync(code, { - filename, - generate: 'dom', - dev, - sourceMap: true, - }); - if (result.map) maps.unshift(JSON.parse(result.map)); - if (inputSourceMap) { - maps.push(typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap); - } - - callback(null, result.code, maps.length ? remapping(maps, () => null) : undefined); - } catch (error) { - callback(error instanceof Error ? error : new Error(String(error))); - } -} diff --git a/rspack/solid/src/index.jsx b/rspack/solid/src/index.jsx index 07412cb87..27c0e53ad 100644 --- a/rspack/solid/src/index.jsx +++ b/rspack/solid/src/index.jsx @@ -1,4 +1,5 @@ -import { render } from '@solidjs/web'; +/* @refresh reload */ +import { render } from 'solid-js/web'; import './index.css'; import App from './App';