Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/refactor-remove-webpack-chain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/react-rsbuild-plugin": patch
---

refactor: remove `modifyWebpackChain` since Rsbuild 2.0 dropped webpack support
16 changes: 3 additions & 13 deletions packages/rspeedy/plugin-react/src/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ import type {
RspackChain,
} from '@rsbuild/core'

import {
ReactRefreshRspackPlugin,
ReactRefreshWebpackPlugin,
} from '@lynx-js/react-refresh-webpack-plugin'
import { ReactRefreshRspackPlugin } from '@lynx-js/react-refresh-webpack-plugin'
import { LAYERS } from '@lynx-js/react-webpack-plugin'

const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh'

export function applyRefresh(api: RsbuildPluginAPI): void {
api.modifyWebpackChain(async (chain, { CHAIN_ID, isProd }) => {
if (!isProd) {
await applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshWebpackPlugin)
}
})

api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID }) => {
if (!isProd) {
// biome-ignore lint/correctness/useHookAtTopLevel: not react hooks
Expand All @@ -41,12 +32,11 @@ export function applyRefresh(api: RsbuildPluginAPI): void {
})
}

async function applyRefreshRules<Bundler extends 'webpack' | 'rspack'>(
async function applyRefreshRules(
api: RsbuildPluginAPI,
chain: RspackChain,
CHAIN_ID: ChainIdentifier,
ReactRefreshPlugin: Bundler extends 'rspack' ? typeof ReactRefreshRspackPlugin
: typeof ReactRefreshWebpackPlugin,
ReactRefreshPlugin: typeof ReactRefreshRspackPlugin,
) {
// biome-ignore lint/correctness/useHookAtTopLevel: not react hooks
const { resolve } = api.useExposed<
Expand Down
Loading