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
8 changes: 8 additions & 0 deletions .changeset/align-refresh-registration-backfill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'rsbuild-plugin-react-router': patch
---

Align the Fast Refresh registration backfill with react-refresh's own
component-detection rules so `memo`/`forwardRef` components in pre-lowered
(MDX) routes register for HMR. Multi-declarator lists, curried arrows, and
require/import interop callees no longer produce false registrations.
5 changes: 5 additions & 0 deletions .changeset/classic-dev-hmr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rsbuild-plugin-react-router': minor
---

Add state-preserving Hot Module Replacement for route modules in development: route updates now apply React Refresh registration and in-place route patching instead of triggering a full page reload. Server code changes also trigger hot data revalidation, so loader data refreshes without a reload. This degrades gracefully to the previous full-reload behavior when `@rsbuild/plugin-react` isn't present or Fast Refresh is disabled.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ build
.unpack-cache/
.codex/
.tracedecay/
.cursor/
.benchmark/
task/upstream/
task/output/
tests/react-router-framework/.tmp/

# Example build outputs
**/build/
Expand Down
5 changes: 5 additions & 0 deletions src/build-output-transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type RegisterBuildOutputTransformsOptions = {
ssr: boolean;
isSpaMode: boolean;
rootRoutePath: string;
isDevHmrEnabled?: () => boolean;
};

export const registerBuildOutputTransforms = ({
Expand All @@ -61,6 +62,7 @@ export const registerBuildOutputTransforms = ({
ssr,
isSpaMode,
rootRoutePath,
isDevHmrEnabled = () => false,
}: RegisterBuildOutputTransformsOptions): void => {
const transformRouteModule = async (args: Parameters<TransformHandler>[0]) =>
performanceProfiler.record(
Expand All @@ -81,6 +83,7 @@ export const registerBuildOutputTransforms = ({
isBuild,
isSpaMode,
rootRoutePath,
devHmr: isDevHmrEnabled(),
})
);

Expand Down Expand Up @@ -158,6 +161,8 @@ export const registerBuildOutputTransforms = ({
environmentName: args.environment?.name,
isBuild,
routeChunkConfig,
routeId: routeByFilePath.get(args.resourcePath)?.id,
devHmr: isDevHmrEnabled(),
})
)
);
Expand Down
Loading
Loading