diff --git a/package.json b/package.json index ee3f7f1..2fe5e4f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@biomejs/biome": "^1.8.3", "@jest/reporters": "29.7.0", "@jest/test-sequencer": "^29.7.0", - "@rspack/core": "npm:@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256", + "@rspack/core": "1.6.4", "@rspack/plugin-react-refresh": "1.0.0", "@types/express": "4.17.21", "@types/jest": "29.5.12", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a6c665..73ee8f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,8 +37,8 @@ importers: specifier: ^29.7.0 version: 29.7.0 '@rspack/core': - specifier: npm:@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256 - version: '@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256' + specifier: 1.6.4 + version: 1.6.4 '@rspack/plugin-react-refresh': specifier: 1.0.0 version: 1.0.0(react-refresh@0.14.0) @@ -62,7 +62,7 @@ importers: version: 7.0.3 css-loader: specifier: ^7.1.2 - version: 7.1.2(@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256)(webpack@5.94.0) + version: 7.1.2(@rspack/core@1.6.4)(webpack@5.94.0) execa: specifier: 9.3.0 version: 9.3.0 @@ -501,96 +501,95 @@ packages: '@leichtgewicht/ip-codec@2.0.5': resolution: {integrity: sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==} - '@module-federation/error-codes@0.15.0': - resolution: {integrity: sha512-CFJSF+XKwTcy0PFZ2l/fSUpR4z247+Uwzp1sXVkdIfJ/ATsnqf0Q01f51qqSEA6MYdQi6FKos9FIcu3dCpQNdg==} + '@module-federation/error-codes@0.21.4': + resolution: {integrity: sha512-ClpL5MereWNXh+EgDjz7w4RrC1JlisQTvXDa1gLxpviHafzNDfdViVmuhi9xXVuj+EYo8KU70Y999KHhk9424Q==} - '@module-federation/runtime-core@0.15.0': - resolution: {integrity: sha512-RYzI61fRDrhyhaEOXH3AgIGlHiot0wPFXu7F43cr+ZnTi+VlSYWLdlZ4NBuT9uV6JSmH54/c+tEZm5SXgKR2sQ==} + '@module-federation/runtime-core@0.21.4': + resolution: {integrity: sha512-SGpmoOLGNxZofpTOk6Lxb2ewaoz5wMi93AFYuuJB04HTVcngEK+baNeUZ2D/xewrqNIJoMY6f5maUjVfIIBPUA==} - '@module-federation/runtime-tools@0.15.0': - resolution: {integrity: sha512-kzFn3ObUeBp5vaEtN1WMxhTYBuYEErxugu1RzFUERD21X3BZ+b4cWwdFJuBDlsmVjctIg/QSOoZoPXRKAO0foA==} + '@module-federation/runtime-tools@0.21.4': + resolution: {integrity: sha512-RzFKaL0DIjSmkn76KZRfzfB6dD07cvID84950jlNQgdyoQFUGkqD80L6rIpVCJTY/R7LzR3aQjHnoqmq4JPo3w==} - '@module-federation/runtime@0.15.0': - resolution: {integrity: sha512-dTPsCNum9Bhu3yPOcrPYq0YnM9eCMMMNB1wuiqf1+sFbQlNApF0vfZxooqz3ln0/MpgE0jerVvFsLVGfqvC9Ug==} + '@module-federation/runtime@0.21.4': + resolution: {integrity: sha512-wgvGqryurVEvkicufJmTG0ZehynCeNLklv8kIk5BLIsWYSddZAE+xe4xov1kgH5fIJQAoQNkRauFFjVNlHoAkA==} - '@module-federation/sdk@0.15.0': - resolution: {integrity: sha512-PWiYbGcJrKUD6JZiEPihrXhV3bgXdll4bV7rU+opV7tHaun+Z0CdcawjZ82Xnpb8MCPGmqHwa1MPFeUs66zksw==} + '@module-federation/sdk@0.21.4': + resolution: {integrity: sha512-tzvhOh/oAfX++6zCDDxuvioHY4Jurf8vcfoCbKFxusjmyKr32GPbwFDazUP+OPhYCc3dvaa9oWU6X/qpUBLfJw==} - '@module-federation/webpack-bundler-runtime@0.15.0': - resolution: {integrity: sha512-i+3wu2Ljh2TmuUpsnjwZVupOVqV50jP0ndA8PSP4gwMKlgdGeaZ4VH5KkHAXGr2eiYUxYLMrJXz1+eILJqeGDg==} + '@module-federation/webpack-bundler-runtime@0.21.4': + resolution: {integrity: sha512-dusmR3uPnQh9u9ChQo3M+GLOuGFthfvnh7WitF/a1eoeTfRmXqnMFsXtZCUK+f/uXf+64874Zj/bhAgbBcVHZA==} - '@napi-rs/wasm-runtime@0.2.12': - resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} + '@napi-rs/wasm-runtime@1.0.7': + resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==} '@puppeteer/browsers@2.4.0': resolution: {integrity: sha512-x8J1csfIygOwf6D6qUAZ0ASk3z63zPb7wkNeHRerCMh82qWKUrOgkuP005AJC8lDL6/evtXETGEJVcwykKT4/g==} engines: {node: '>=18'} hasBin: true - '@rspack-canary/binding-darwin-arm64@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-x8CAVBOeunQBftEwOOHJSVRTUXlfK9jQCaJS7inNE47G7SaVFtFAOGw6DBTTUplmX8eJ+QapVBaPVg95gYELQg==} + '@rspack/binding-darwin-arm64@1.6.4': + resolution: {integrity: sha512-qD2C5xwdY2qKEXTZiPJQx1L1kELapOc0AaZDqcAyzXs30d1qTKpx6PdyW3HN+gueKovyWZwMMYfz6RxcMCnaDQ==} cpu: [arm64] os: [darwin] - '@rspack-canary/binding-darwin-x64@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-kZsoki8s+6s1KGp7qhjLeqfI1toolqfhXCfNGV5V2Gyw8bFCUpwcfXvfoR4DFgVdqhLj6Fd10BBbfbM6kNILtw==} + '@rspack/binding-darwin-x64@1.6.4': + resolution: {integrity: sha512-IHceyLDxeubqIrGz4gUqJavnygTij4vtDDE2Fkgobz7hkTJwGtD5mxBKbVNRqGvhrasVw0h9rEjR7tdbDSiUhQ==} cpu: [x64] os: [darwin] - '@rspack-canary/binding-linux-arm64-gnu@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-fn88EEKfJrC94e4Zi57prT53NSPey+hTe6ZI9mFlm9pkGXgWAvMdzxy/sc061ct88yn0oezfFEzuNHtby0HeuA==} + '@rspack/binding-linux-arm64-gnu@1.6.4': + resolution: {integrity: sha512-Ldpoz2wWnBaL2+XKLIOyCZMkAkd4pk/L24EVgma3SpRtwgenLEr10bQupvwGAK5OLkjayslOTZmRiAv0FH5o/w==} cpu: [arm64] os: [linux] - '@rspack-canary/binding-linux-arm64-musl@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-0285DQ2fRf3cZlGKVRA8Ab4Y9t6bhPZnJPxo3oDrKddxNPOLVzrXBAZDlb4uwHFIcQd11OrgecNvNcCKI0zL9Q==} + '@rspack/binding-linux-arm64-musl@1.6.4': + resolution: {integrity: sha512-3fLMSDK5yMjKmx7iFbYG3P3A0xNdtmNu09v5P6hzq65tkJ3dflIt3p8DvtOTURtuSgQZV2A1LDd9hpIXdnigqA==} cpu: [arm64] os: [linux] - '@rspack-canary/binding-linux-x64-gnu@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-Ls8Yhe2ZS79OxDaK3bn2i2QF6nZKCRxpAy6XB7lbD0dDG2JW9/ON+iKpltwinTtwIO2d7K2qKJwubDzqTYnQIA==} + '@rspack/binding-linux-x64-gnu@1.6.4': + resolution: {integrity: sha512-5YzXUKLnaiqND05CDgkKE0WNRtC1ulkVncYs78xPikonzZmgVXa8eRaTPOZC6ZjpLR0eTsg+MSesLUsPUu27hA==} cpu: [x64] os: [linux] - '@rspack-canary/binding-linux-x64-musl@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-svXr4ryHICO9F7K5+muG3r5ErjnceiyhgBjbP0pVg2uftATuJBeBLsoB4FDrTtM4TWI78leB9VNmQyKF3FsSVg==} + '@rspack/binding-linux-x64-musl@1.6.4': + resolution: {integrity: sha512-KcSFla8a9bXG1mmV5oQ1R5h/dSXfd41/qHOsNuLqho2UCX8CVh4dezUA153dj7p1S4yOhTy6VZZi6C1szweE9A==} cpu: [x64] os: [linux] - '@rspack-canary/binding-wasm32-wasi@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-quXMvknMtfnsblnocDNDYK/HNmUQq22CYjqQSRKiUFnIxTbTwsXu1vGs/186PXTQUQZctFNSJnoKbRSt3SN1TQ==} + '@rspack/binding-wasm32-wasi@1.6.4': + resolution: {integrity: sha512-mfFJbDJkRy5I1iW3m0JlWbc0X8pjVd+GRUz5nhbccwEhSQOc27ao3evf7XPU4aaDxud1B3UEqYiRcRmtm1BrjA==} cpu: [wasm32] - '@rspack-canary/binding-win32-arm64-msvc@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-SI0WhzKK2gjvBBBQFCX3RSNLw/UWo7MKyqKir/bFfxiv/DksIPEbXB2IZ8bjd6vtYTcg3ZprCqcuJdnLARvQ/A==} + '@rspack/binding-win32-arm64-msvc@1.6.4': + resolution: {integrity: sha512-QtIqxsfeTSS1lwfaPGrPFfJ9ir/3aWZv5t3iAgYj/CNUA8MTKWt4vQKcco7NRIGK4ZLMI+dgJBFtvd/lUDMQsw==} cpu: [arm64] os: [win32] - '@rspack-canary/binding-win32-ia32-msvc@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-Zci5Oo3A+Go5O2QIXBzypwokEtBTyQaoLvqppCl4olcD/a63+vGiKCh/GWYBxLIcYiqFyLWJyEG1IgeRwYJGDg==} + '@rspack/binding-win32-ia32-msvc@1.6.4': + resolution: {integrity: sha512-HXEWGDllgh0jFwjGhkGcLqb0dzXbc/rA8vQr2JcSdC41p1DTzLgO215jWdKSIvzCzhyPh3VeQkXk76hjFB2cLQ==} cpu: [ia32] os: [win32] - '@rspack-canary/binding-win32-x64-msvc@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-FPrOiNyfoLJRfOn/7NeHO2Be7451+dVbJwFIYYLjWgGtZZBvWKY3/EQDlm/YDkSo1wzMKfu8XLee8jjHKhYF5A==} + '@rspack/binding-win32-x64-msvc@1.6.4': + resolution: {integrity: sha512-MAO5rOnGYoeuT2LPn/P7JVJCi3d78XoXgOq3tkGh6qXhvhkjsBRtYluWCzACXQpXfFHEWYd7uT5yHoZgxiVuoA==} cpu: [x64] os: [win32] - '@rspack-canary/binding@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-cwJ5WjPmQQ+quuA4wYkIPTAEOt7VeRZP7x2sgxJDjLRyooC1OJtS00XFqNWjLAerrE0jskFWFKV4rgIeKymw8Q==} + '@rspack/binding@1.6.4': + resolution: {integrity: sha512-vUxc/zUdsCuyysOvP4CTdIYxsZPb2jIXST5vrLABiTPIaHpXZ0hVdgKif2XPJwJeuCVS6w25xvyPN0mBCU0MvQ==} - '@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256': - resolution: {integrity: sha512-ge9y0DyVi8IW3AkKKlS8BeFy9Xq1Sbftt632RIM/7ExVwuBTZg/w5y9Uf1RbiWpWfNjMZnnxZSOFI3VXmF6UOQ==} - engines: {node: '>=16.0.0'} + '@rspack/core@1.6.4': + resolution: {integrity: sha512-5F1+MQD8rfbFbUHnaiZe4jqOu9pnSb+PliqQvi0lj+uvpMpcS3sJDIs/mz6P1u87lfkfBXChIT4zSLAzeOgMWw==} + engines: {node: '>=18.12.0'} peerDependencies: '@swc/helpers': '>=0.5.1' peerDependenciesMeta: '@swc/helpers': optional: true - '@rspack/lite-tapable@1.0.1': - resolution: {integrity: sha512-VynGOEsVw2s8TAlLf/uESfrgfrq2+rcXB1muPJYBWbsm1Oa6r5qVQhjA5ggM6z/coYPrsVMgovl3Ff7Q7OCp1w==} - engines: {node: '>=16.0.0'} + '@rspack/lite-tapable@1.1.0': + resolution: {integrity: sha512-E2B0JhYFmVAwdDiG14+DW0Di4Ze4Jg10Pc4/lILUrd5DRCaklduz2OvJ5HYQ6G+hd+WTzqQb3QnDNfK4yvAFYw==} '@rspack/plugin-react-refresh@1.0.0': resolution: {integrity: sha512-WvXkLewW5G0Mlo5H1b251yDh5FFiH4NDAbYlFpvFjcuXX2AchZRf9zdw57BDE/ADyWsJgA8kixN/zZWBTN3iYA==} @@ -3387,32 +3386,32 @@ snapshots: '@leichtgewicht/ip-codec@2.0.5': {} - '@module-federation/error-codes@0.15.0': {} + '@module-federation/error-codes@0.21.4': {} - '@module-federation/runtime-core@0.15.0': + '@module-federation/runtime-core@0.21.4': dependencies: - '@module-federation/error-codes': 0.15.0 - '@module-federation/sdk': 0.15.0 + '@module-federation/error-codes': 0.21.4 + '@module-federation/sdk': 0.21.4 - '@module-federation/runtime-tools@0.15.0': + '@module-federation/runtime-tools@0.21.4': dependencies: - '@module-federation/runtime': 0.15.0 - '@module-federation/webpack-bundler-runtime': 0.15.0 + '@module-federation/runtime': 0.21.4 + '@module-federation/webpack-bundler-runtime': 0.21.4 - '@module-federation/runtime@0.15.0': + '@module-federation/runtime@0.21.4': dependencies: - '@module-federation/error-codes': 0.15.0 - '@module-federation/runtime-core': 0.15.0 - '@module-federation/sdk': 0.15.0 + '@module-federation/error-codes': 0.21.4 + '@module-federation/runtime-core': 0.21.4 + '@module-federation/sdk': 0.21.4 - '@module-federation/sdk@0.15.0': {} + '@module-federation/sdk@0.21.4': {} - '@module-federation/webpack-bundler-runtime@0.15.0': + '@module-federation/webpack-bundler-runtime@0.21.4': dependencies: - '@module-federation/runtime': 0.15.0 - '@module-federation/sdk': 0.15.0 + '@module-federation/runtime': 0.21.4 + '@module-federation/sdk': 0.21.4 - '@napi-rs/wasm-runtime@0.2.12': + '@napi-rs/wasm-runtime@1.0.7': dependencies: '@emnapi/core': 1.6.0 '@emnapi/runtime': 1.6.0 @@ -3432,58 +3431,58 @@ snapshots: transitivePeerDependencies: - supports-color - '@rspack-canary/binding-darwin-arm64@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-darwin-arm64@1.6.4': optional: true - '@rspack-canary/binding-darwin-x64@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-darwin-x64@1.6.4': optional: true - '@rspack-canary/binding-linux-arm64-gnu@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-linux-arm64-gnu@1.6.4': optional: true - '@rspack-canary/binding-linux-arm64-musl@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-linux-arm64-musl@1.6.4': optional: true - '@rspack-canary/binding-linux-x64-gnu@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-linux-x64-gnu@1.6.4': optional: true - '@rspack-canary/binding-linux-x64-musl@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-linux-x64-musl@1.6.4': optional: true - '@rspack-canary/binding-wasm32-wasi@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-wasm32-wasi@1.6.4': dependencies: - '@napi-rs/wasm-runtime': 0.2.12 + '@napi-rs/wasm-runtime': 1.0.7 optional: true - '@rspack-canary/binding-win32-arm64-msvc@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-win32-arm64-msvc@1.6.4': optional: true - '@rspack-canary/binding-win32-ia32-msvc@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-win32-ia32-msvc@1.6.4': optional: true - '@rspack-canary/binding-win32-x64-msvc@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding-win32-x64-msvc@1.6.4': optional: true - '@rspack-canary/binding@1.4.3-canary-98b815e4-20250703091256': + '@rspack/binding@1.6.4': optionalDependencies: - '@rspack/binding-darwin-arm64': '@rspack-canary/binding-darwin-arm64@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-darwin-x64': '@rspack-canary/binding-darwin-x64@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-linux-arm64-gnu': '@rspack-canary/binding-linux-arm64-gnu@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-linux-arm64-musl': '@rspack-canary/binding-linux-arm64-musl@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-linux-x64-gnu': '@rspack-canary/binding-linux-x64-gnu@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-linux-x64-musl': '@rspack-canary/binding-linux-x64-musl@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-wasm32-wasi': '@rspack-canary/binding-wasm32-wasi@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-win32-arm64-msvc': '@rspack-canary/binding-win32-arm64-msvc@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-win32-ia32-msvc': '@rspack-canary/binding-win32-ia32-msvc@1.4.3-canary-98b815e4-20250703091256' - '@rspack/binding-win32-x64-msvc': '@rspack-canary/binding-win32-x64-msvc@1.4.3-canary-98b815e4-20250703091256' + '@rspack/binding-darwin-arm64': 1.6.4 + '@rspack/binding-darwin-x64': 1.6.4 + '@rspack/binding-linux-arm64-gnu': 1.6.4 + '@rspack/binding-linux-arm64-musl': 1.6.4 + '@rspack/binding-linux-x64-gnu': 1.6.4 + '@rspack/binding-linux-x64-musl': 1.6.4 + '@rspack/binding-wasm32-wasi': 1.6.4 + '@rspack/binding-win32-arm64-msvc': 1.6.4 + '@rspack/binding-win32-ia32-msvc': 1.6.4 + '@rspack/binding-win32-x64-msvc': 1.6.4 - '@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256': + '@rspack/core@1.6.4': dependencies: - '@module-federation/runtime-tools': 0.15.0 - '@rspack/binding': '@rspack-canary/binding@1.4.3-canary-98b815e4-20250703091256' - '@rspack/lite-tapable': 1.0.1 + '@module-federation/runtime-tools': 0.21.4 + '@rspack/binding': 1.6.4 + '@rspack/lite-tapable': 1.1.0 - '@rspack/lite-tapable@1.0.1': {} + '@rspack/lite-tapable@1.1.0': {} '@rspack/plugin-react-refresh@1.0.0(react-refresh@0.14.0)': dependencies: @@ -4135,7 +4134,7 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - css-loader@7.1.2(@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256)(webpack@5.94.0): + css-loader@7.1.2(@rspack/core@1.6.4)(webpack@5.94.0): dependencies: icss-utils: 5.1.0(postcss@8.4.47) postcss: 8.4.47 @@ -4146,7 +4145,7 @@ snapshots: postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: - '@rspack/core': '@rspack-canary/core@1.4.3-canary-98b815e4-20250703091256' + '@rspack/core': 1.6.4 webpack: 5.94.0 cssesc@3.0.0: {} diff --git a/src/server.ts b/src/server.ts index e033b86..5cfc511 100644 --- a/src/server.ts +++ b/src/server.ts @@ -9,7 +9,7 @@ */ import type { Server } from "node:http"; import type { Socket } from "node:net"; -import { type Compiler, MultiCompiler } from "@rspack/core"; +import { type Compiler, DefinePlugin, MultiCompiler } from "@rspack/core"; import type { FSWatcher } from "chokidar"; import WebpackDevServer from "webpack-dev-server"; // @ts-ignore 'package.json' is not under 'rootDir' @@ -79,6 +79,8 @@ export class RspackDevServer extends WebpackDevServer { ? this.compiler.compilers : [this.compiler]; + const compilerForDev = compilers[0]; + for (const compiler of compilers) { const mode = compiler.options.mode || process.env.NODE_ENV; if (this.options.hot) { @@ -100,6 +102,22 @@ export class RspackDevServer extends WebpackDevServer { // @ts-expect-error await super.initialize(); + + // now we have the exact URI + this.defineDevServerUri(compilerForDev); + } + + defineDevServerUri(compiler: Compiler) { + new DefinePlugin({ + __rspack_dev_server_uri: JSON.stringify(this.getDevServerUri()) + }).apply(compiler); + } + + getDevServerUri() { + const protocol = this.options.server.type; + const hostname = this.options.host || "127.0.0.1"; + const port = this.options.port; + return `${protocol}://${hostname}:${port}`; } getClientEntry(): string {