diff --git a/.changeset/small-moles-crash.md b/.changeset/small-moles-crash.md new file mode 100644 index 000000000000..221abf602770 --- /dev/null +++ b/.changeset/small-moles-crash.md @@ -0,0 +1,8 @@ +--- +'@modern-js/builder-rspack-provider': patch +'@modern-js/storybook-builder': patch +--- + +chore: replace @rspack/dev-client with @rspack/plugin-react-refresh + +chore: 将 @rspack/dev-client 替换为 @rspack/plugin-react-refresh diff --git a/packages/builder/builder-rspack-provider/package.json b/packages/builder/builder-rspack-provider/package.json index 98db2725f15d..e355deb1777d 100644 --- a/packages/builder/builder-rspack-provider/package.json +++ b/packages/builder/builder-rspack-provider/package.json @@ -57,7 +57,7 @@ "@modern-js/utils": "workspace:*", "@babel/preset-typescript": "^7.22.15", "@rspack/core": "0.4.1", - "@rspack/dev-client": "0.4.1", + "@rspack/plugin-react-refresh": "0.4.1", "@rspack/plugin-html": "0.4.1", "@swc/helpers": "0.5.3", "rspack-manifest-plugin": "5.0.0-alpha0", diff --git a/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts b/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts index bfe0934caca7..791897e81342 100644 --- a/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts +++ b/packages/builder/builder-rspack-provider/src/core/devMiddleware.ts @@ -12,7 +12,7 @@ export function getHotRuntimeEntries(compiler: Compiler) { if (hot && refresh) { const reactRefreshEntryPath = require.resolve( - '@rspack/dev-client/react-refresh-entry', + '@rspack/plugin-react-refresh/react-refresh-entry', ); return [reactRefreshEntryPath]; } diff --git a/packages/builder/builder-rspack-provider/src/plugins/react.ts b/packages/builder/builder-rspack-provider/src/plugins/react.ts index 2a14b6faa8c0..ba3aa0256a55 100644 --- a/packages/builder/builder-rspack-provider/src/plugins/react.ts +++ b/packages/builder/builder-rspack-provider/src/plugins/react.ts @@ -53,7 +53,7 @@ export const builderPluginReact = (): BuilderPlugin => ({ chain.plugin('ReactRefreshRuntime').use(bundler.ProvidePlugin, [ { $ReactRefreshRuntime$: [ - require.resolve('@rspack/dev-client/react-refresh'), + require.resolve('@rspack/plugin-react-refresh/react-refresh'), ], }, ]); diff --git a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap index 546ef37fe465..a4c0a3152651 100644 --- a/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap +++ b/packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap @@ -703,7 +703,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = ` ProvidePlugin { "_options": { "$ReactRefreshRuntime$": [ - "/node_modules//@rspack/dev-client/src/reactRefresh.js", + "/node_modules//@rspack/plugin-react-refresh/client/reactRefresh.js", ], }, "name": "ProvidePlugin", @@ -2682,7 +2682,7 @@ exports[`tools.rspack > should match snapshot 1`] = ` ProvidePlugin { "_options": { "$ReactRefreshRuntime$": [ - "/node_modules//@rspack/dev-client/src/reactRefresh.js", + "/node_modules//@rspack/plugin-react-refresh/client/reactRefresh.js", ], }, "name": "ProvidePlugin", diff --git a/packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx b/packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx index f9539d80ed2a..cbde43f0a613 100644 --- a/packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx +++ b/packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx @@ -83,7 +83,7 @@ For example, if you are using pnpm, you can update the Rspack version with `over "pnpm": { "overrides": { "@rspack/core": "nightly", - "@rspack/dev-client": "nightly", + "@rspack/plugin-react-refresh": "nightly", "@rspack/plugin-html": "nightly" } } diff --git a/packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx b/packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx index 918498bc9ad7..485697ac0506 100644 --- a/packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx +++ b/packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx @@ -83,7 +83,7 @@ import RspackPrecautions from '@modern-js/builder-doc/docs/zh/shared/rspackPreca "pnpm": { "overrides": { "@rspack/core": "nightly", - "@rspack/dev-client": "nightly", + "@rspack/plugin-react-refresh": "nightly", "@rspack/plugin-html": "nightly" } } diff --git a/packages/storybook/builder/package.json b/packages/storybook/builder/package.json index d55e15ed4006..eee13f3b4888 100644 --- a/packages/storybook/builder/package.json +++ b/packages/storybook/builder/package.json @@ -61,7 +61,7 @@ "@modern-js/core": "workspace:*", "@modern-js/runtime": "workspace:*", "@modern-js/utils": "workspace:*", - "@rspack/dev-client": "0.4.1", + "@rspack/plugin-react-refresh": "0.4.1", "@storybook/components": "~7.6.1", "@storybook/core-common": "~7.6.1", "@storybook/csf-plugin": "~7.6.1", diff --git a/packages/storybook/builder/src/preset.ts b/packages/storybook/builder/src/preset.ts index 64a88cd2d754..6d8d5d7cb420 100644 --- a/packages/storybook/builder/src/preset.ts +++ b/packages/storybook/builder/src/preset.ts @@ -26,7 +26,7 @@ export const entries = async (_: unknown, options: Options) => { )}?reload=true&quiet=false&noInfo=${options.quiet}`, bundler === 'rspack' - ? require.resolve('@rspack/dev-client/react-refresh-entry') + ? require.resolve('@rspack/plugin-react-refresh/react-refresh-entry') : null, ].filter(Boolean) as string[]), ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb3fa0db8d03..e3fb4a128df1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -176,12 +176,12 @@ importers: '@rspack/core': specifier: 0.4.1 version: 0.4.1 - '@rspack/dev-client': - specifier: 0.4.1 - version: 0.4.1(react-refresh@0.14.0)(webpack@5.88.1) '@rspack/plugin-html': specifier: 0.4.1 version: 0.4.1(@rspack/core@0.4.1) + '@rspack/plugin-react-refresh': + specifier: 0.4.1 + version: 0.4.1(react-refresh@0.14.0)(webpack@5.88.1) '@swc/helpers': specifier: 0.5.3 version: 0.5.3 @@ -4814,7 +4814,7 @@ importers: '@modern-js/utils': specifier: workspace:* version: link:../../toolkit/utils - '@rspack/dev-client': + '@rspack/plugin-react-refresh': specifier: 0.4.1 version: 0.4.1(react-refresh@0.14.0)(webpack-hot-middleware@2.25.4)(webpack@5.89.0) '@storybook/components': @@ -15510,46 +15510,6 @@ packages: zod-validation-error: 1.3.1(zod@3.22.3) dev: false - /@rspack/dev-client@0.4.1(react-refresh@0.14.0)(webpack-hot-middleware@2.25.4)(webpack@5.89.0): - resolution: {integrity: sha512-RKJJ3I6apbZgDAVWAJvZ2usts3OEgcufyHQHlDKfqlrEjOX4kkfIA02O+6RTjB/Bx412r8AiAZzpXges1X+xGA==} - peerDependencies: - react-refresh: '>=0.10.0 <1.0.0' - peerDependenciesMeta: - react-refresh: - optional: true - dependencies: - '@rspack/plugin-react-refresh': 0.4.1(react-refresh@0.14.0)(webpack-hot-middleware@2.25.4)(webpack@5.89.0) - react-refresh: 0.14.0 - transitivePeerDependencies: - - '@types/webpack' - - sockjs-client - - type-fest - - webpack - - webpack-dev-server - - webpack-hot-middleware - - webpack-plugin-serve - dev: false - - /@rspack/dev-client@0.4.1(react-refresh@0.14.0)(webpack@5.88.1): - resolution: {integrity: sha512-RKJJ3I6apbZgDAVWAJvZ2usts3OEgcufyHQHlDKfqlrEjOX4kkfIA02O+6RTjB/Bx412r8AiAZzpXges1X+xGA==} - peerDependencies: - react-refresh: '>=0.10.0 <1.0.0' - peerDependenciesMeta: - react-refresh: - optional: true - dependencies: - '@rspack/plugin-react-refresh': 0.4.1(react-refresh@0.14.0)(webpack@5.88.1) - react-refresh: 0.14.0 - transitivePeerDependencies: - - '@types/webpack' - - sockjs-client - - type-fest - - webpack - - webpack-dev-server - - webpack-hot-middleware - - webpack-plugin-serve - dev: false - /@rspack/plugin-html@0.4.1(@rspack/core@0.4.1): resolution: {integrity: sha512-tjUO0Vntn0GIIHT6eQXv5FuOr6erXDfGRHeimm5DDCdcO8ibqlCsXsUA6E/sU9iI6usazl6/TO1C25gQLFCblw==} peerDependencies: