@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.96 → 3.2.0-ultramodern.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ wrapTanstackSsrHydrationBoundary: ()=>wrapTanstackSsrHydrationBoundary
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const external_react_namespaceObject = require("react");
31
+ function wrapTanstackSsrHydrationBoundary(routerContent, shouldWrap) {
32
+ return shouldWrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Suspense, {
33
+ fallback: null,
34
+ children: routerContent
35
+ }) : routerContent;
36
+ }
37
+ exports.wrapTanstackSsrHydrationBoundary = __webpack_exports__.wrapTanstackSsrHydrationBoundary;
38
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
39
+ "wrapTanstackSsrHydrationBoundary"
40
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
41
+ Object.defineProperty(exports, '__esModule', {
42
+ value: true
43
+ });
@@ -36,6 +36,7 @@ const client_namespaceObject = require("@tanstack/react-router/ssr/client");
36
36
  const external_react_namespaceObject = require("react");
37
37
  const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
38
38
  const external_hooks_js_namespaceObject = require("./hooks.js");
39
+ const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
39
40
  const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
40
41
  const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
41
42
  const external_routeTree_js_namespaceObject = require("./routeTree.js");
@@ -223,6 +224,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
223
224
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
224
225
  router: router
225
226
  });
227
+ const HydratableRouterContent = (0, external_hydrationBoundary_js_namespaceObject.wrapTanstackSsrHydrationBoundary)(RouterContent, hasSSRBootstrap);
226
228
  if (hasSSRBootstrap) hooks.onAfterHydrateRouter.call({
227
229
  ...lifecycleContext,
228
230
  phase: 'hydrate',
@@ -230,8 +232,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
230
232
  runtimeContext: runtimeState
231
233
  });
232
234
  return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
233
- children: RouterContent
234
- }) : RouterContent;
235
+ children: HydratableRouterContent
236
+ }) : HydratableRouterContent;
235
237
  };
236
238
  return RouterWrapper;
237
239
  });
@@ -38,6 +38,7 @@ const server_namespaceObject = require("@tanstack/router-core/ssr/server");
38
38
  const external_react_namespaceObject = require("react");
39
39
  const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
40
40
  const external_hooks_js_namespaceObject = require("./hooks.js");
41
+ const external_hydrationBoundary_js_namespaceObject = require("./hydrationBoundary.js");
41
42
  const external_lifecycle_js_namespaceObject = require("./lifecycle.js");
42
43
  const external_routeTree_js_namespaceObject = require("./routeTree.js");
43
44
  const payloadRouter_js_namespaceObject = require("./rsc/payloadRouter.js");
@@ -296,9 +297,9 @@ const tanstackRouterPlugin = (userConfig = {})=>{
296
297
  if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
297
298
  ...props
298
299
  }) : null;
299
- const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
300
+ const routerWrapper = (0, external_hydrationBoundary_js_namespaceObject.wrapTanstackSsrHydrationBoundary)(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
300
301
  router: router
301
- });
302
+ }), true);
302
303
  return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
303
304
  children: routerWrapper
304
305
  }) : routerWrapper;
@@ -0,0 +1,9 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ function wrapTanstackSsrHydrationBoundary(routerContent, shouldWrap) {
4
+ return shouldWrap ? /*#__PURE__*/ jsx(Suspense, {
5
+ fallback: null,
6
+ children: routerContent
7
+ }) : routerContent;
8
+ }
9
+ export { wrapTanstackSsrHydrationBoundary };
@@ -7,6 +7,7 @@ import { RouterClient } from "@tanstack/react-router/ssr/client";
7
7
  import { useContext, useMemo } from "react";
8
8
  import { createModernBasepathRewrite } from "./basepathRewrite.mjs";
9
9
  import { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter } from "./hooks.mjs";
10
+ import { wrapTanstackSsrHydrationBoundary } from "./hydrationBoundary.mjs";
10
11
  import { applyRouterRuntimeState } from "./lifecycle.mjs";
11
12
  import { Link } from "./prefetchLink.mjs";
12
13
  import { createRouteTreeFromRouteObjects } from "./routeTree.mjs";
@@ -194,6 +195,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
194
195
  }) : /*#__PURE__*/ jsx(RouterProvider, {
195
196
  router: router
196
197
  });
198
+ const HydratableRouterContent = wrapTanstackSsrHydrationBoundary(RouterContent, hasSSRBootstrap);
197
199
  if (hasSSRBootstrap) hooks.onAfterHydrateRouter.call({
198
200
  ...lifecycleContext,
199
201
  phase: 'hydrate',
@@ -201,8 +203,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
201
203
  runtimeContext: runtimeState
202
204
  });
203
205
  return App ? /*#__PURE__*/ jsx(App, {
204
- children: RouterContent
205
- }) : RouterContent;
206
+ children: HydratableRouterContent
207
+ }) : HydratableRouterContent;
206
208
  };
207
209
  return RouterWrapper;
208
210
  });
@@ -9,6 +9,7 @@ import { attachRouterServerSsrUtils } from "@tanstack/router-core/ssr/server";
9
9
  import { useContext } from "react";
10
10
  import { createModernBasepathRewrite } from "./basepathRewrite.mjs";
11
11
  import { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter } from "./hooks.mjs";
12
+ import { wrapTanstackSsrHydrationBoundary } from "./hydrationBoundary.mjs";
12
13
  import { applyRouterServerPrepareResult, createRouterServerSnapshot } from "./lifecycle.mjs";
13
14
  import { createRouteTreeFromRouteObjects, getModernRouteIdsFromMatches } from "./routeTree.mjs";
14
15
  import { createTanstackRscServerPayload, handleTanstackRscRedirect } from "./rsc/payloadRouter.mjs";
@@ -267,9 +268,9 @@ const tanstackRouterPlugin = (userConfig = {})=>{
267
268
  if (!router) return App ? /*#__PURE__*/ jsx(App, {
268
269
  ...props
269
270
  }) : null;
270
- const routerWrapper = /*#__PURE__*/ jsx(RouterProvider, {
271
+ const routerWrapper = wrapTanstackSsrHydrationBoundary(/*#__PURE__*/ jsx(RouterProvider, {
271
272
  router: router
272
- });
273
+ }), true);
273
274
  return App ? /*#__PURE__*/ jsx(App, {
274
275
  children: routerWrapper
275
276
  }) : routerWrapper;
@@ -0,0 +1,10 @@
1
+ import "node:module";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { Suspense } from "react";
4
+ function wrapTanstackSsrHydrationBoundary(routerContent, shouldWrap) {
5
+ return shouldWrap ? /*#__PURE__*/ jsx(Suspense, {
6
+ fallback: null,
7
+ children: routerContent
8
+ }) : routerContent;
9
+ }
10
+ export { wrapTanstackSsrHydrationBoundary };
@@ -8,6 +8,7 @@ import { RouterClient } from "@tanstack/react-router/ssr/client";
8
8
  import { useContext, useMemo } from "react";
9
9
  import { createModernBasepathRewrite } from "./basepathRewrite.mjs";
10
10
  import { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter } from "./hooks.mjs";
11
+ import { wrapTanstackSsrHydrationBoundary } from "./hydrationBoundary.mjs";
11
12
  import { applyRouterRuntimeState } from "./lifecycle.mjs";
12
13
  import { Link } from "./prefetchLink.mjs";
13
14
  import { createRouteTreeFromRouteObjects } from "./routeTree.mjs";
@@ -195,6 +196,7 @@ const tanstackRouterPlugin = (userConfig = {})=>{
195
196
  }) : /*#__PURE__*/ jsx(RouterProvider, {
196
197
  router: router
197
198
  });
199
+ const HydratableRouterContent = wrapTanstackSsrHydrationBoundary(RouterContent, hasSSRBootstrap);
198
200
  if (hasSSRBootstrap) hooks.onAfterHydrateRouter.call({
199
201
  ...lifecycleContext,
200
202
  phase: 'hydrate',
@@ -202,8 +204,8 @@ const tanstackRouterPlugin = (userConfig = {})=>{
202
204
  runtimeContext: runtimeState
203
205
  });
204
206
  return App ? /*#__PURE__*/ jsx(App, {
205
- children: RouterContent
206
- }) : RouterContent;
207
+ children: HydratableRouterContent
208
+ }) : HydratableRouterContent;
207
209
  };
208
210
  return RouterWrapper;
209
211
  });
@@ -10,6 +10,7 @@ import { attachRouterServerSsrUtils } from "@tanstack/router-core/ssr/server";
10
10
  import { useContext } from "react";
11
11
  import { createModernBasepathRewrite } from "./basepathRewrite.mjs";
12
12
  import { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter } from "./hooks.mjs";
13
+ import { wrapTanstackSsrHydrationBoundary } from "./hydrationBoundary.mjs";
13
14
  import { applyRouterServerPrepareResult, createRouterServerSnapshot } from "./lifecycle.mjs";
14
15
  import { createRouteTreeFromRouteObjects, getModernRouteIdsFromMatches } from "./routeTree.mjs";
15
16
  import { createTanstackRscServerPayload, handleTanstackRscRedirect } from "./rsc/payloadRouter.mjs";
@@ -268,9 +269,9 @@ const tanstackRouterPlugin = (userConfig = {})=>{
268
269
  if (!router) return App ? /*#__PURE__*/ jsx(App, {
269
270
  ...props
270
271
  }) : null;
271
- const routerWrapper = /*#__PURE__*/ jsx(RouterProvider, {
272
+ const routerWrapper = wrapTanstackSsrHydrationBoundary(/*#__PURE__*/ jsx(RouterProvider, {
272
273
  router: router
273
- });
274
+ }), true);
274
275
  return App ? /*#__PURE__*/ jsx(App, {
275
276
  children: routerWrapper
276
277
  }) : routerWrapper;
@@ -0,0 +1,2 @@
1
+ import { type ReactElement } from 'react';
2
+ export declare function wrapTanstackSsrHydrationBoundary(routerContent: ReactElement, shouldWrap: boolean): import("react").JSX.Element;
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.2.0-ultramodern.96",
21
+ "version": "3.2.0-ultramodern.97",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -88,13 +88,13 @@
88
88
  "@swc/helpers": "^0.5.23",
89
89
  "@tanstack/react-router": "1.170.11",
90
90
  "@tanstack/router-core": "1.171.9",
91
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.96",
92
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.96",
93
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.96",
94
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.96"
91
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.97",
92
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.97",
93
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.97",
94
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.97"
95
95
  },
96
96
  "peerDependencies": {
97
- "@modern-js/runtime": "3.2.0-ultramodern.96",
97
+ "@modern-js/runtime": "3.2.0-ultramodern.97",
98
98
  "react": "^19.2.6",
99
99
  "react-dom": "^19.2.6"
100
100
  },
@@ -109,9 +109,9 @@
109
109
  "@typescript/native-preview": "7.0.0-dev.20260527.2",
110
110
  "react": "^19.2.6",
111
111
  "react-dom": "^19.2.6",
112
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.96",
113
- "@scripts/rstest-config": "2.66.0",
114
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.96"
112
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.97",
113
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.97",
114
+ "@scripts/rstest-config": "2.66.0"
115
115
  },
116
116
  "sideEffects": false,
117
117
  "publishConfig": {
@@ -0,0 +1,12 @@
1
+ import { type ReactElement, Suspense } from 'react';
2
+
3
+ export function wrapTanstackSsrHydrationBoundary(
4
+ routerContent: ReactElement,
5
+ shouldWrap: boolean,
6
+ ) {
7
+ return shouldWrap ? (
8
+ <Suspense fallback={null}>{routerContent}</Suspense>
9
+ ) : (
10
+ routerContent
11
+ );
12
+ }
@@ -39,6 +39,7 @@ import {
39
39
  onBeforeHydrateRouter as onBeforeHydrateRouterHook,
40
40
  type RouterExtendsHooks,
41
41
  } from './hooks';
42
+ import { wrapTanstackSsrHydrationBoundary } from './hydrationBoundary';
42
43
  import {
43
44
  applyRouterServerPrepareResult,
44
45
  createRouterServerSnapshot,
@@ -564,8 +565,9 @@ export const tanstackRouterPlugin = (
564
565
  return App ? <App {...props} /> : null;
565
566
  }
566
567
 
567
- const routerWrapper = (
568
- <RouterProvider router={router as AnyRouter} />
568
+ const routerWrapper = wrapTanstackSsrHydrationBoundary(
569
+ <RouterProvider router={router as AnyRouter} />,
570
+ true,
569
571
  );
570
572
 
571
573
  return App ? <App>{routerWrapper}</App> : routerWrapper;
@@ -36,6 +36,7 @@ import {
36
36
  onBeforeHydrateRouter as onBeforeHydrateRouterHook,
37
37
  type RouterExtendsHooks,
38
38
  } from './hooks';
39
+ import { wrapTanstackSsrHydrationBoundary } from './hydrationBoundary';
39
40
  import {
40
41
  applyRouterRuntimeState,
41
42
  type RouterLifecycleContext,
@@ -377,6 +378,10 @@ export const tanstackRouterPlugin = (
377
378
  ) : (
378
379
  <RouterProvider router={router} />
379
380
  );
381
+ const HydratableRouterContent = wrapTanstackSsrHydrationBoundary(
382
+ RouterContent,
383
+ hasSSRBootstrap,
384
+ );
380
385
  if (hasSSRBootstrap) {
381
386
  hooks.onAfterHydrateRouter.call({
382
387
  ...lifecycleContext,
@@ -386,7 +391,11 @@ export const tanstackRouterPlugin = (
386
391
  });
387
392
  }
388
393
 
389
- return App ? <App>{RouterContent}</App> : RouterContent;
394
+ return App ? (
395
+ <App>{HydratableRouterContent}</App>
396
+ ) : (
397
+ HydratableRouterContent
398
+ );
390
399
  };
391
400
 
392
401
  return RouterWrapper;
@@ -0,0 +1,23 @@
1
+ import { isValidElement, Suspense } from 'react';
2
+ import { wrapTanstackSsrHydrationBoundary } from '../../src/runtime/hydrationBoundary';
3
+
4
+ describe('tanstack SSR hydration boundary', () => {
5
+ it('wraps SSR hydration content in a Suspense boundary', () => {
6
+ const routerContent = <main data-testid="router" />;
7
+
8
+ const wrapped = wrapTanstackSsrHydrationBoundary(routerContent, true);
9
+
10
+ expect(isValidElement(wrapped)).toBe(true);
11
+ expect(wrapped.type).toBe(Suspense);
12
+ expect(wrapped.props.fallback).toBe(null);
13
+ expect(wrapped.props.children).toBe(routerContent);
14
+ });
15
+
16
+ it('keeps non-SSR router content unwrapped', () => {
17
+ const routerContent = <main data-testid="router" />;
18
+
19
+ expect(wrapTanstackSsrHydrationBoundary(routerContent, false)).toBe(
20
+ routerContent,
21
+ );
22
+ });
23
+ });