diff --git a/.changeset/fair-llamas-hydrate.md b/.changeset/fair-llamas-hydrate.md new file mode 100644 index 0000000000..b5e62c0ede --- /dev/null +++ b/.changeset/fair-llamas-hydrate.md @@ -0,0 +1,8 @@ +--- +'@tanstack/react-start': patch +'@tanstack/react-start-client': patch +'@tanstack/solid-start': patch +'@tanstack/solid-start-client': patch +--- + +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. diff --git a/packages/react-start-client/package.json b/packages/react-start-client/package.json index af06d2b008..41e72258e0 100644 --- a/packages/react-start-client/package.json +++ b/packages/react-start-client/package.json @@ -54,6 +54,12 @@ "default": "./dist/esm/hydration.js" } }, + "./Hydrate": { + "import": { + "types": "./dist/esm/Hydrate.d.ts", + "default": "./dist/esm/Hydrate.js" + } + }, "./package.json": "./package.json" }, "sideEffects": false, diff --git a/packages/react-start-client/src/index.tsx b/packages/react-start-client/src/index.tsx index 669b1e0e3f..26e7195c39 100644 --- a/packages/react-start-client/src/index.tsx +++ b/packages/react-start-client/src/index.tsx @@ -2,17 +2,3 @@ export { StartClient } from './StartClient' export { hydrateStart } from './hydrateStart' -export { Hydrate } from './Hydrate' -export type { - HydrateOptions, - HydrateProps, - HydrateWhen, - HydrationInteractionEvent, - HydrationInteractionEvents, - HydrationPrefetchContext, - HydrationPrefetchFunction, - HydrationPrefetchStrategy, - HydrationPrefetchWaitReason, - HydrationStrategy, - HydrationWhen, -} from './Hydrate' diff --git a/packages/react-start-client/vite.config.ts b/packages/react-start-client/vite.config.ts index 40e07174ac..19e0d79d19 100644 --- a/packages/react-start-client/vite.config.ts +++ b/packages/react-start-client/vite.config.ts @@ -20,7 +20,7 @@ export default mergeConfig( tanstackViteConfig({ tsconfigPath: './tsconfig.build.json', srcDir: './src', - entry: ['./src/index.tsx', './src/hydration.ts'], + entry: ['./src/index.tsx', './src/Hydrate.tsx', './src/hydration.ts'], cjs: false, }), ) diff --git a/packages/react-start/src/index.ts b/packages/react-start/src/index.ts index 0947745215..6ea839a967 100644 --- a/packages/react-start/src/index.ts +++ b/packages/react-start/src/index.ts @@ -15,7 +15,14 @@ export { createServerOnlyFn, createStart, } from '@tanstack/start-client-core' -export { Hydrate } from '@tanstack/react-start-client' + +// Keep root `@tanstack/react-start` imports from evaluating the client barrel. +// The barrel also exports `hydrateStart`, which imports the virtual client +// entry. That virtual entry imports the user's router module, so route modules +// that import the root package can be pulled back into the same graph and +// create circular HMR updates. Re-exporting from the Hydrate-only subpath +// preserves the public API without introducing that import edge. +export { Hydrate } from '@tanstack/react-start-client/Hydrate' export type { HydrateOptions, HydrateProps, @@ -24,4 +31,4 @@ export type { HydrationPrefetchStrategy, HydrationStrategy, HydrationWhen, -} from '@tanstack/react-start-client' +} from '@tanstack/react-start-client/Hydrate' diff --git a/packages/solid-start-client/package.json b/packages/solid-start-client/package.json index 61b66cce1d..ca542c9014 100644 --- a/packages/solid-start-client/package.json +++ b/packages/solid-start-client/package.json @@ -54,6 +54,12 @@ "default": "./dist/esm/hydration.js" } }, + "./Hydrate": { + "import": { + "types": "./dist/esm/Hydrate.d.ts", + "default": "./dist/esm/Hydrate.js" + } + }, "./package.json": "./package.json" }, "sideEffects": false, diff --git a/packages/solid-start-client/src/index.tsx b/packages/solid-start-client/src/index.tsx index 2128ebcb01..aa73990a57 100644 --- a/packages/solid-start-client/src/index.tsx +++ b/packages/solid-start-client/src/index.tsx @@ -1,16 +1,2 @@ export { StartClient } from './StartClient' export { hydrateStart } from './hydrateStart' -export { Hydrate } from './Hydrate' -export type { - HydrateOptions, - HydrateProps, - HydrateWhen, - HydrationInteractionEvent, - HydrationInteractionEvents, - HydrationPrefetchContext, - HydrationPrefetchFunction, - HydrationPrefetchStrategy, - HydrationPrefetchWaitReason, - HydrationStrategy, - HydrationWhen, -} from './Hydrate' diff --git a/packages/solid-start/src/index.ts b/packages/solid-start/src/index.ts index 44d8c36c88..bc5560978d 100644 --- a/packages/solid-start/src/index.ts +++ b/packages/solid-start/src/index.ts @@ -15,7 +15,14 @@ export { createServerOnlyFn, createStart, } from '@tanstack/start-client-core' -export { Hydrate } from '@tanstack/solid-start-client' + +// Keep root `@tanstack/solid-start` imports from evaluating the client barrel. +// The barrel also exports `hydrateStart`, which imports the virtual client +// entry. That virtual entry imports the user's router module, so route modules +// that import the root package can be pulled back into the same graph and +// create circular HMR updates. Re-exporting from the Hydrate-only subpath +// preserves the public API without introducing that import edge. +export { Hydrate } from '@tanstack/solid-start-client/Hydrate' export type { HydrateOptions, HydrateProps, @@ -24,4 +31,4 @@ export type { HydrationPrefetchStrategy, HydrationStrategy, HydrationWhen, -} from '@tanstack/solid-start-client' +} from '@tanstack/solid-start-client/Hydrate'