Skip to content

Commit aff3daa

Browse files
fix: Fix Hydrate re-exports to avoid circular HMR updates
1 parent aee3661 commit aff3daa

8 files changed

Lines changed: 39 additions & 33 deletions

File tree

‎.changeset/fair-llamas-hydrate.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@tanstack/react-start': patch
3+
'@tanstack/react-start-client': patch
4+
'@tanstack/solid-start': patch
5+
'@tanstack/solid-start-client': patch
6+
---
7+
8+
Avoid pulling the client hydration entry into root `@tanstack/react-start` and `@tanstack/solid-start` imports by re-exporting `Hydrate` from framework client Hydrate-only subpaths.

‎packages/react-start-client/package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
"default": "./dist/esm/hydration.js"
5555
}
5656
},
57+
"./Hydrate": {
58+
"import": {
59+
"types": "./dist/esm/Hydrate.d.ts",
60+
"default": "./dist/esm/Hydrate.js"
61+
}
62+
},
5763
"./package.json": "./package.json"
5864
},
5965
"sideEffects": false,

‎packages/react-start-client/src/index.tsx‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,3 @@
22

33
export { StartClient } from './StartClient'
44
export { hydrateStart } from './hydrateStart'
5-
export { Hydrate } from './Hydrate'
6-
export type {
7-
HydrateOptions,
8-
HydrateProps,
9-
HydrateWhen,
10-
HydrationInteractionEvent,
11-
HydrationInteractionEvents,
12-
HydrationPrefetchContext,
13-
HydrationPrefetchFunction,
14-
HydrationPrefetchStrategy,
15-
HydrationPrefetchWaitReason,
16-
HydrationStrategy,
17-
HydrationWhen,
18-
} from './Hydrate'

‎packages/react-start-client/vite.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default mergeConfig(
2020
tanstackViteConfig({
2121
tsconfigPath: './tsconfig.build.json',
2222
srcDir: './src',
23-
entry: ['./src/index.tsx', './src/hydration.ts'],
23+
entry: ['./src/index.tsx', './src/Hydrate.tsx', './src/hydration.ts'],
2424
cjs: false,
2525
}),
2626
)

‎packages/react-start/src/index.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ export {
1515
createServerOnlyFn,
1616
createStart,
1717
} from '@tanstack/start-client-core'
18-
export { Hydrate } from '@tanstack/react-start-client'
18+
19+
// Keep root `@tanstack/react-start` imports from evaluating the client barrel.
20+
// The barrel also exports `hydrateStart`, which imports the virtual client
21+
// entry. That virtual entry imports the user's router module, so route modules
22+
// that import the root package can be pulled back into the same graph and
23+
// create circular HMR updates. Re-exporting from the Hydrate-only subpath
24+
// preserves the public API without introducing that import edge.
25+
export { Hydrate } from '@tanstack/react-start-client/Hydrate'
1926
export type {
2027
HydrateOptions,
2128
HydrateProps,
@@ -24,4 +31,4 @@ export type {
2431
HydrationPrefetchStrategy,
2532
HydrationStrategy,
2633
HydrationWhen,
27-
} from '@tanstack/react-start-client'
34+
} from '@tanstack/react-start-client/Hydrate'

‎packages/solid-start-client/package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
"default": "./dist/esm/hydration.js"
5555
}
5656
},
57+
"./Hydrate": {
58+
"import": {
59+
"types": "./dist/esm/Hydrate.d.ts",
60+
"default": "./dist/esm/Hydrate.js"
61+
}
62+
},
5763
"./package.json": "./package.json"
5864
},
5965
"sideEffects": false,
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,2 @@
11
export { StartClient } from './StartClient'
22
export { hydrateStart } from './hydrateStart'
3-
export { Hydrate } from './Hydrate'
4-
export type {
5-
HydrateOptions,
6-
HydrateProps,
7-
HydrateWhen,
8-
HydrationInteractionEvent,
9-
HydrationInteractionEvents,
10-
HydrationPrefetchContext,
11-
HydrationPrefetchFunction,
12-
HydrationPrefetchStrategy,
13-
HydrationPrefetchWaitReason,
14-
HydrationStrategy,
15-
HydrationWhen,
16-
} from './Hydrate'

‎packages/solid-start/src/index.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ export {
1515
createServerOnlyFn,
1616
createStart,
1717
} from '@tanstack/start-client-core'
18-
export { Hydrate } from '@tanstack/solid-start-client'
18+
19+
// Keep root `@tanstack/solid-start` imports from evaluating the client barrel.
20+
// The barrel also exports `hydrateStart`, which imports the virtual client
21+
// entry. That virtual entry imports the user's router module, so route modules
22+
// that import the root package can be pulled back into the same graph and
23+
// create circular HMR updates. Re-exporting from the Hydrate-only subpath
24+
// preserves the public API without introducing that import edge.
25+
export { Hydrate } from '@tanstack/solid-start-client/Hydrate'
1926
export type {
2027
HydrateOptions,
2128
HydrateProps,
@@ -24,4 +31,4 @@ export type {
2431
HydrationPrefetchStrategy,
2532
HydrationStrategy,
2633
HydrationWhen,
27-
} from '@tanstack/solid-start-client'
34+
} from '@tanstack/solid-start-client/Hydrate'

0 commit comments

Comments
 (0)