@bleedingdev/modern-js-plugin-tanstack 3.9.0-ultramodern.4 → 3.9.0-ultramodern.6

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.
Files changed (55) hide show
  1. package/dist/cjs/cli/index.js +9 -0
  2. package/dist/cjs/runtime/lifecycle.js +7 -7
  3. package/dist/cjs/runtime/prefetchLink.js +2 -7
  4. package/dist/cjs/runtime/register.js +0 -2
  5. package/dist/cjs/runtime/router.js +25 -9
  6. package/dist/cjs/runtime/state.js +2 -2
  7. package/dist/esm/cli/index.mjs +9 -0
  8. package/dist/esm/runtime/lifecycle.mjs +1 -1
  9. package/dist/esm/runtime/prefetchLink.mjs +1 -6
  10. package/dist/esm/runtime/register.mjs +0 -2
  11. package/dist/esm/runtime/router.mjs +27 -11
  12. package/dist/esm/runtime/state.mjs +1 -1
  13. package/dist/esm-node/cli/index.mjs +9 -0
  14. package/dist/esm-node/runtime/lifecycle.mjs +1 -1
  15. package/dist/esm-node/runtime/prefetchLink.mjs +1 -6
  16. package/dist/esm-node/runtime/register.mjs +0 -2
  17. package/dist/esm-node/runtime/router.mjs +27 -11
  18. package/dist/esm-node/runtime/state.mjs +1 -1
  19. package/dist/types/runtime/lifecycle.d.ts +9 -2
  20. package/dist/types/runtime/register.d.ts +1 -9
  21. package/dist/types/runtime/router.d.ts +2 -13
  22. package/dist/types/runtime/state.d.ts +1 -1
  23. package/dist/types/runtime/types.d.ts +2 -1
  24. package/package.json +12 -10
  25. package/rstest.config.mts +0 -21
  26. package/src/cli/index.ts +10 -0
  27. package/src/runtime/lifecycle.ts +14 -3
  28. package/src/runtime/plugin.node.tsx +1 -1
  29. package/src/runtime/prefetchLink.tsx +1 -23
  30. package/src/runtime/register.ts +1 -12
  31. package/src/runtime/router.ts +25 -40
  32. package/src/runtime/state.ts +1 -1
  33. package/src/runtime/types.ts +2 -2
  34. package/tests/realm-isolation.test.ts +7 -17
  35. package/tests/router/cli.test.ts +105 -8
  36. package/tests/router/dataMutation.test.tsx +17 -121
  37. package/tests/router/flightSerialization.roundtrip.test.tsx +9 -6
  38. package/tests/router/generateRouteArtifacts.test.ts +69 -29
  39. package/tests/router/hooks.test.ts +1 -18
  40. package/tests/router/loaderBridge.test.ts +0 -77
  41. package/tests/router/prefetchLink.test.tsx +28 -16
  42. package/tests/router/prefetchLinkPreload.test.tsx +21 -28
  43. package/tests/router/routeHooks.test.ts +41 -105
  44. package/tests/router/routeTree.test.ts +0 -212
  45. package/tests/router/rsc.test.tsx +118 -136
  46. package/tests/router/rscDecoderSecurity.test.ts +24 -53
  47. package/tests/router/tanstackTypes.test.ts +24 -364
  48. package/tests/router/fastDefaults.test.ts +0 -32
  49. package/tests/router/fixtures/legacyRuntimeRouter.ts +0 -10
  50. package/tests/router/hydrationBoundary.test.tsx +0 -23
  51. package/tests/router/packageSurface.test.ts +0 -24
  52. package/tests/router/preloadRedirect.test.ts +0 -64
  53. package/tests/router/register.test.ts +0 -8
  54. package/tests/router/routerCompatibility.test.ts +0 -239
  55. package/tests/router/rscPayloadRouterMatrix.test.ts +0 -197
@@ -91,6 +91,15 @@ var __webpack_exports__ = {};
91
91
  '@modern-js/runtime'
92
92
  ],
93
93
  setup: (api)=>{
94
+ const { srcDirectory, serverCompileExcludedFiles = [] } = api.getAppContext();
95
+ api.updateAppContext({
96
+ serverCompileExcludedFiles: [
97
+ ...new Set([
98
+ ...serverCompileExcludedFiles,
99
+ external_node_path_default().join(srcDirectory, generatedDirName, 'register.gen.d.ts')
100
+ ])
101
+ ]
102
+ });
94
103
  const nestedRoutesForServer = {};
95
104
  const isTanstackEntrypoint = (entrypoint)=>{
96
105
  const { getEntrypointRoutesDir } = getRuntimeRouterCli();
@@ -28,14 +28,14 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
- applyRouterRuntimeState: ()=>context_namespaceObject.applyRouterRuntimeState,
32
- applyRouterServerPrepareResult: ()=>context_namespaceObject.applyRouterServerPrepareResult,
33
- createRouterRuntimeState: ()=>context_namespaceObject.createRouterRuntimeState,
34
- createRouterServerSnapshot: ()=>context_namespaceObject.createRouterServerSnapshot,
35
- getRouterRuntimeState: ()=>context_namespaceObject.getRouterRuntimeState,
36
- getRouterServerSnapshot: ()=>context_namespaceObject.getRouterServerSnapshot
31
+ applyRouterRuntimeState: ()=>router_state_namespaceObject.applyRouterRuntimeState,
32
+ applyRouterServerPrepareResult: ()=>router_state_namespaceObject.applyRouterServerPrepareResult,
33
+ createRouterRuntimeState: ()=>router_state_namespaceObject.createRouterRuntimeState,
34
+ createRouterServerSnapshot: ()=>router_state_namespaceObject.createRouterServerSnapshot,
35
+ getRouterRuntimeState: ()=>router_state_namespaceObject.getRouterRuntimeState,
36
+ getRouterServerSnapshot: ()=>router_state_namespaceObject.getRouterServerSnapshot
37
37
  });
38
- const context_namespaceObject = require("@modern-js/runtime/context");
38
+ const router_state_namespaceObject = require("@modern-js/runtime-extensions/router-state");
39
39
  exports.applyRouterRuntimeState = __webpack_exports__.applyRouterRuntimeState;
40
40
  exports.applyRouterServerPrepareResult = __webpack_exports__.applyRouterServerPrepareResult;
41
41
  exports.createRouterRuntimeState = __webpack_exports__.createRouterRuntimeState;
@@ -32,19 +32,14 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  NavLink: ()=>NavLink
33
33
  });
34
34
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
35
+ const runtime_extensions_namespaceObject = require("@modern-js/runtime-extensions");
35
36
  const react_router_namespaceObject = require("@tanstack/react-router");
36
- function resolvePreloadFromPrefetch(prefetch, preload) {
37
- if (void 0 !== preload) return preload;
38
- if ('none' === prefetch) return false;
39
- if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
40
- return 'viewport';
41
- }
42
37
  const LinkComponentImpl = (props)=>{
43
38
  const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
44
39
  const hasAriaCurrentOverride = 'aria-current' in props;
45
40
  const linkOptions = {
46
41
  ...rest,
47
- preload: resolvePreloadFromPrefetch(prefetch, preload)
42
+ preload: (0, runtime_extensions_namespaceObject.resolvePreloadFromPrefetch)(prefetch, preload)
48
43
  };
49
44
  const linkProps = (0, react_router_namespaceObject.useLinkProps)(linkOptions, ref);
50
45
  const { disabled: _disabled, type: _type, ...anchorProps } = linkProps;
@@ -30,10 +30,8 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  tanstackRouterProviderFactory: ()=>tanstackRouterProviderFactory
32
32
  });
33
- const context_namespaceObject = require("@modern-js/runtime/context");
34
33
  const external_plugin_js_namespaceObject = require("./plugin.js");
35
34
  const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
36
- (0, context_namespaceObject.registerRouterProvider)('tanstack', tanstackRouterProviderFactory);
37
35
  exports.tanstackRouterProviderFactory = __webpack_exports__.tanstackRouterProviderFactory;
38
36
  for(var __rspack_i in __webpack_exports__)if (-1 === [
39
37
  "tanstackRouterProviderFactory"
@@ -30,21 +30,37 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  routerPlugin: ()=>routerPlugin
32
32
  });
33
+ const context_namespaceObject = require("@modern-js/runtime/context");
33
34
  const internal_namespaceObject = require("@modern-js/runtime/router/internal");
35
+ const router_provider_namespaceObject = require("@modern-js/runtime-extensions/router-provider");
36
+ const router_state_plugin_namespaceObject = require("@modern-js/runtime-extensions/router-state-plugin");
34
37
  const external_register_js_namespaceObject = require("./register.js");
35
- function getRouterPlugin() {
36
- const createRouterPlugin = Reflect.get(internal_namespaceObject, 'createRouterPlugin');
37
- if ('function' == typeof createRouterPlugin) return createRouterPlugin([
38
+ const createProviderPlugin = (0, router_provider_namespaceObject.createRouterPlugin)({
39
+ defaultProvider: {
40
+ name: 'react-router',
41
+ factory: internal_namespaceObject.routerPlugin
42
+ },
43
+ registryHooks: context_namespaceObject.routerProviderRegistryHooks,
44
+ localProviders: [
38
45
  {
39
46
  name: 'tanstack',
40
47
  factory: external_register_js_namespaceObject.tanstackRouterProviderFactory
41
48
  }
42
- ]);
43
- const legacyRouterPlugin = Reflect.get(internal_namespaceObject, 'routerPlugin');
44
- if ('function' == typeof legacyRouterPlugin) return external_register_js_namespaceObject.tanstackRouterProviderFactory;
45
- throw new Error('[@modern-js/plugin-tanstack] The installed @modern-js/runtime/router/internal exports neither createRouterPlugin nor routerPlugin. Install a compatible @modern-js/runtime version.');
46
- }
47
- const routerPlugin = getRouterPlugin();
49
+ ]
50
+ });
51
+ const statePlugin = (0, router_state_plugin_namespaceObject.createRouterStatePlugin)({
52
+ registryHooks: context_namespaceObject.routerProviderRegistryHooks
53
+ });
54
+ const routerPlugin = (userConfig = {})=>{
55
+ const providerPlugin = createProviderPlugin(userConfig);
56
+ return {
57
+ ...providerPlugin,
58
+ setup (api) {
59
+ statePlugin.setup(api);
60
+ providerPlugin.setup(api);
61
+ }
62
+ };
63
+ };
48
64
  exports.routerPlugin = __webpack_exports__.routerPlugin;
49
65
  for(var __rspack_i in __webpack_exports__)if (-1 === [
50
66
  "routerPlugin"
@@ -30,9 +30,9 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  getTanstackRouterState: ()=>getTanstackRouterState
32
32
  });
33
- const context_namespaceObject = require("@modern-js/runtime/context");
33
+ const router_state_namespaceObject = require("@modern-js/runtime-extensions/router-state");
34
34
  function getTanstackRouterState(context) {
35
- const state = (0, context_namespaceObject.getRouterRuntimeState)(context);
35
+ const state = (0, router_state_namespaceObject.getRouterRuntimeState)(context);
36
36
  if (void 0 === state || 'tanstack' !== state.framework || void 0 === state.instance) return;
37
37
  return state;
38
38
  }
@@ -31,6 +31,15 @@ function tanstackRouterPlugin(options = {}) {
31
31
  '@modern-js/runtime'
32
32
  ],
33
33
  setup: (api)=>{
34
+ const { srcDirectory, serverCompileExcludedFiles = [] } = api.getAppContext();
35
+ api.updateAppContext({
36
+ serverCompileExcludedFiles: [
37
+ ...new Set([
38
+ ...serverCompileExcludedFiles,
39
+ node_path.join(srcDirectory, generatedDirName, 'register.gen.d.ts')
40
+ ])
41
+ ]
42
+ });
34
43
  const nestedRoutesForServer = {};
35
44
  const isTanstackEntrypoint = (entrypoint)=>{
36
45
  const { getEntrypointRoutesDir } = getRuntimeRouterCli();
@@ -1 +1 @@
1
- export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot } from "@modern-js/runtime/context";
1
+ export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot } from "@modern-js/runtime-extensions/router-state";
@@ -1,11 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { resolvePreloadFromPrefetch } from "@modern-js/runtime-extensions";
2
3
  import { useLinkProps } from "@tanstack/react-router";
3
- function resolvePreloadFromPrefetch(prefetch, preload) {
4
- if (void 0 !== preload) return preload;
5
- if ('none' === prefetch) return false;
6
- if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
7
- return 'viewport';
8
- }
9
4
  const LinkComponentImpl = (props)=>{
10
5
  const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
11
6
  const hasAriaCurrentOverride = 'aria-current' in props;
@@ -1,5 +1,3 @@
1
- import { registerRouterProvider } from "@modern-js/runtime/context";
2
1
  import { tanstackRouterPlugin } from "./plugin.mjs";
3
2
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
4
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);
5
3
  export { tanstackRouterProviderFactory };
@@ -1,16 +1,32 @@
1
- import * as __rspack_external__modern_js_runtime_router_internal_8b8183c5 from "@modern-js/runtime/router/internal";
1
+ import { routerProviderRegistryHooks } from "@modern-js/runtime/context";
2
+ import { routerPlugin } from "@modern-js/runtime/router/internal";
3
+ import { createRouterPlugin } from "@modern-js/runtime-extensions/router-provider";
4
+ import { createRouterStatePlugin } from "@modern-js/runtime-extensions/router-state-plugin";
2
5
  import { tanstackRouterProviderFactory } from "./register.mjs";
3
- function getRouterPlugin() {
4
- const createRouterPlugin = Reflect.get(__rspack_external__modern_js_runtime_router_internal_8b8183c5, 'createRouterPlugin');
5
- if ('function' == typeof createRouterPlugin) return createRouterPlugin([
6
+ const createProviderPlugin = createRouterPlugin({
7
+ defaultProvider: {
8
+ name: 'react-router',
9
+ factory: routerPlugin
10
+ },
11
+ registryHooks: routerProviderRegistryHooks,
12
+ localProviders: [
6
13
  {
7
14
  name: 'tanstack',
8
15
  factory: tanstackRouterProviderFactory
9
16
  }
10
- ]);
11
- const legacyRouterPlugin = Reflect.get(__rspack_external__modern_js_runtime_router_internal_8b8183c5, 'routerPlugin');
12
- if ('function' == typeof legacyRouterPlugin) return tanstackRouterProviderFactory;
13
- throw new Error('[@modern-js/plugin-tanstack] The installed @modern-js/runtime/router/internal exports neither createRouterPlugin nor routerPlugin. Install a compatible @modern-js/runtime version.');
14
- }
15
- const routerPlugin = getRouterPlugin();
16
- export { routerPlugin };
17
+ ]
18
+ });
19
+ const statePlugin = createRouterStatePlugin({
20
+ registryHooks: routerProviderRegistryHooks
21
+ });
22
+ const router_routerPlugin = (userConfig = {})=>{
23
+ const providerPlugin = createProviderPlugin(userConfig);
24
+ return {
25
+ ...providerPlugin,
26
+ setup (api) {
27
+ statePlugin.setup(api);
28
+ providerPlugin.setup(api);
29
+ }
30
+ };
31
+ };
32
+ export { router_routerPlugin as routerPlugin };
@@ -1,4 +1,4 @@
1
- import { getRouterRuntimeState } from "@modern-js/runtime/context";
1
+ import { getRouterRuntimeState } from "@modern-js/runtime-extensions/router-state";
2
2
  function getTanstackRouterState(context) {
3
3
  const state = getRouterRuntimeState(context);
4
4
  if (void 0 === state || 'tanstack' !== state.framework || void 0 === state.instance) return;
@@ -37,6 +37,15 @@ function tanstackRouterPlugin(options = {}) {
37
37
  '@modern-js/runtime'
38
38
  ],
39
39
  setup: (api)=>{
40
+ const { srcDirectory, serverCompileExcludedFiles = [] } = api.getAppContext();
41
+ api.updateAppContext({
42
+ serverCompileExcludedFiles: [
43
+ ...new Set([
44
+ ...serverCompileExcludedFiles,
45
+ node_path.join(srcDirectory, generatedDirName, 'register.gen.d.ts')
46
+ ])
47
+ ]
48
+ });
40
49
  const nestedRoutesForServer = {};
41
50
  const isTanstackEntrypoint = (entrypoint)=>{
42
51
  const { getEntrypointRoutesDir } = getRuntimeRouterCli();
@@ -1,2 +1,2 @@
1
1
  import "node:module";
2
- export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot } from "@modern-js/runtime/context";
2
+ export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot } from "@modern-js/runtime-extensions/router-state";
@@ -1,12 +1,7 @@
1
1
  import "node:module";
2
2
  import { jsx } from "react/jsx-runtime";
3
+ import { resolvePreloadFromPrefetch } from "@modern-js/runtime-extensions";
3
4
  import { useLinkProps } from "@tanstack/react-router";
4
- function resolvePreloadFromPrefetch(prefetch, preload) {
5
- if (void 0 !== preload) return preload;
6
- if ('none' === prefetch) return false;
7
- if ('intent' === prefetch || 'render' === prefetch || 'viewport' === prefetch) return prefetch;
8
- return 'viewport';
9
- }
10
5
  const LinkComponentImpl = (props)=>{
11
6
  const { prefetch, preload, 'aria-current': ariaCurrentProp, ref, children, ...rest } = props;
12
7
  const hasAriaCurrentOverride = 'aria-current' in props;
@@ -1,6 +1,4 @@
1
1
  import "node:module";
2
- import { registerRouterProvider } from "@modern-js/runtime/context";
3
2
  import { tanstackRouterPlugin } from "./plugin.mjs";
4
3
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
5
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);
6
4
  export { tanstackRouterProviderFactory };
@@ -1,17 +1,33 @@
1
1
  import "node:module";
2
- import * as __rspack_external__modern_js_runtime_router_internal_8b8183c5 from "@modern-js/runtime/router/internal";
2
+ import { routerProviderRegistryHooks } from "@modern-js/runtime/context";
3
+ import { routerPlugin } from "@modern-js/runtime/router/internal";
4
+ import { createRouterPlugin } from "@modern-js/runtime-extensions/router-provider";
5
+ import { createRouterStatePlugin } from "@modern-js/runtime-extensions/router-state-plugin";
3
6
  import { tanstackRouterProviderFactory } from "./register.mjs";
4
- function getRouterPlugin() {
5
- const createRouterPlugin = Reflect.get(__rspack_external__modern_js_runtime_router_internal_8b8183c5, 'createRouterPlugin');
6
- if ('function' == typeof createRouterPlugin) return createRouterPlugin([
7
+ const createProviderPlugin = createRouterPlugin({
8
+ defaultProvider: {
9
+ name: 'react-router',
10
+ factory: routerPlugin
11
+ },
12
+ registryHooks: routerProviderRegistryHooks,
13
+ localProviders: [
7
14
  {
8
15
  name: 'tanstack',
9
16
  factory: tanstackRouterProviderFactory
10
17
  }
11
- ]);
12
- const legacyRouterPlugin = Reflect.get(__rspack_external__modern_js_runtime_router_internal_8b8183c5, 'routerPlugin');
13
- if ('function' == typeof legacyRouterPlugin) return tanstackRouterProviderFactory;
14
- throw new Error('[@modern-js/plugin-tanstack] The installed @modern-js/runtime/router/internal exports neither createRouterPlugin nor routerPlugin. Install a compatible @modern-js/runtime version.');
15
- }
16
- const routerPlugin = getRouterPlugin();
17
- export { routerPlugin };
18
+ ]
19
+ });
20
+ const statePlugin = createRouterStatePlugin({
21
+ registryHooks: routerProviderRegistryHooks
22
+ });
23
+ const router_routerPlugin = (userConfig = {})=>{
24
+ const providerPlugin = createProviderPlugin(userConfig);
25
+ return {
26
+ ...providerPlugin,
27
+ setup (api) {
28
+ statePlugin.setup(api);
29
+ providerPlugin.setup(api);
30
+ }
31
+ };
32
+ };
33
+ export { router_routerPlugin as routerPlugin };
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { getRouterRuntimeState } from "@modern-js/runtime/context";
2
+ import { getRouterRuntimeState } from "@modern-js/runtime-extensions/router-state";
3
3
  function getTanstackRouterState(context) {
4
4
  const state = getRouterRuntimeState(context);
5
5
  if (void 0 === state || 'tanstack' !== state.framework || void 0 === state.instance) return;
@@ -1,7 +1,14 @@
1
1
  /**
2
- * The router runtime state helpers are owned by @modern-js/runtime (the same
2
+ * The router runtime state helpers are owned by @modern-js/runtime-extensions (the same
3
3
  * implementation backs the built-in react-router provider and the SSR
4
4
  * pipeline). This module only re-exports them so every router provider
5
5
  * writes to the exact same runtime-context extension slot.
6
6
  */
7
- export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot, type RouterLifecycleContext, type RouterLifecyclePhase, } from '@modern-js/runtime/context';
7
+ import type { RouterLifecycleContext as NativeRouterLifecycleContext } from '@modern-js/runtime/context';
8
+ import type { InternalRouterServerSnapshot, RouterRouteMatchSnapshot } from '@modern-js/runtime-extensions/router-state';
9
+ export type RouterLifecycleContext = NativeRouterLifecycleContext & {
10
+ matches?: RouterRouteMatchSnapshot[];
11
+ cleanup?: () => void | Promise<void>;
12
+ serverSnapshot?: InternalRouterServerSnapshot;
13
+ };
14
+ export { applyRouterRuntimeState, applyRouterServerPrepareResult, createRouterRuntimeState, createRouterServerSnapshot, getRouterRuntimeState, getRouterServerSnapshot, type RouterLifecyclePhase, } from '@modern-js/runtime-extensions/router-state';
@@ -1,10 +1,2 @@
1
- /**
2
- * Registers TanStack in the @modern-js/runtime compatibility registry.
3
- * Runtime entries bind the exported local factory into their own provider
4
- * realm; registration remains for older runtime wrappers and mixed cohorts.
5
- *
6
- * This module is intentionally side-effectful (see `sideEffects` in
7
- * package.json).
8
- */
9
- import { type RouterProviderFactory } from '@modern-js/runtime/context';
1
+ import { type RouterProviderFactory } from '@modern-js/runtime-extensions/router-provider';
10
2
  export declare const tanstackRouterProviderFactory: RouterProviderFactory;
@@ -1,13 +1,2 @@
1
- /**
2
- * Entry-injected router module for entrypoints that are NOT TanStack
3
- * file-route entrypoints (e.g. apps configuring
4
- * `router: { framework: 'tanstack', createRoutes }` in modern.runtime.ts).
5
- *
6
- * The CLI plugin injects `{ name: 'router', path: '<pkg>/runtime/router' }`
7
- * for those entries. This module creates a framework-resolving wrapper whose
8
- * app-owned provider realm contains this module graph's TanStack factory.
9
- */
10
- import * as runtimeRouter from '@modern-js/runtime/router/internal';
11
- type LegacyRouterPlugin = (typeof runtimeRouter)['routerPlugin'];
12
- export declare const routerPlugin: LegacyRouterPlugin;
13
- export {};
1
+ import { routerPlugin as nativeRouterPlugin } from '@modern-js/runtime/router/internal';
2
+ export declare const routerPlugin: typeof nativeRouterPlugin;
@@ -1,4 +1,4 @@
1
- import { type InternalRouterRuntimeState } from '@modern-js/runtime/context';
1
+ import { type InternalRouterRuntimeState } from '@modern-js/runtime-extensions/router-state';
2
2
  import type { AnyRouter } from '@tanstack/react-router';
3
3
  /**
4
4
  * Router runtime state as published by the TanStack router provider into the
@@ -1,7 +1,8 @@
1
1
  import type { ModernRoute } from '@modern-js/runtime/context';
2
2
  import type { RouteObject } from '@modern-js/runtime-utils/router';
3
3
  import type React from 'react';
4
- export type { InternalRouterServerSnapshot, ModernRoute, RouterFramework, } from '@modern-js/runtime/context';
4
+ export type { ModernRoute } from '@modern-js/runtime/context';
5
+ export type { InternalRouterServerSnapshot, RouterFramework, } from '@modern-js/runtime-extensions/router-state';
5
6
  /** TanStack-specific router config. */
6
7
  export type RouterConfig = {
7
8
  routesConfig: {
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.9.0-ultramodern.4",
21
+ "version": "3.9.0-ultramodern.6",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -94,18 +94,19 @@
94
94
  }
95
95
  },
96
96
  "dependencies": {
97
- "@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.0-ultramodern.4",
98
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.4",
99
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.4",
100
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.4",
101
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.4",
97
+ "@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.0-ultramodern.6",
98
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.6",
99
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.6",
100
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.6",
101
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.6",
102
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.6",
102
103
  "@swc/helpers": "^0.5.23",
103
104
  "@tanstack/react-router": "1.170.33",
104
105
  "@tanstack/router-core": "1.171.28"
105
106
  },
106
107
  "peerDependencies": {
107
- "@modern-js/app-tools": "3.9.0-ultramodern.4",
108
- "@modern-js/runtime": "3.9.0-ultramodern.4",
108
+ "@modern-js/app-tools": "3.9.0-ultramodern.6",
109
+ "@modern-js/runtime": "3.9.0-ultramodern.6",
109
110
  "react": "^19.2.8",
110
111
  "react-dom": "^19.2.8",
111
112
  "react-server-dom-rspack": "0.1.0"
@@ -116,8 +117,9 @@
116
117
  }
117
118
  },
118
119
  "devDependencies": {
119
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.4",
120
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.4",
120
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.6",
121
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.6",
122
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.6",
121
123
  "@rslib/core": "1.0.0",
122
124
  "@scripts/rstest-config": "2.66.0",
123
125
  "@tanstack/history": "1.162.2",
package/rstest.config.mts CHANGED
@@ -1,4 +1,3 @@
1
- import path from 'node:path';
2
1
  import type { ProjectConfig } from '@rstest/core';
3
2
  import { withTestPreset } from '@scripts/rstest-config';
4
3
 
@@ -26,19 +25,14 @@ export default {
26
25
  include: [
27
26
  'tests/realm-isolation.test.ts',
28
27
  'tests/router/cli.test.ts',
29
- 'tests/router/fastDefaults.test.ts',
30
28
  'tests/router/flightSerialization.roundtrip.test.tsx',
31
29
  'tests/router/generateRouteArtifacts.test.ts',
32
30
  'tests/router/hooks.test.ts',
33
31
  'tests/router/loaderBridge.test.ts',
34
32
  'tests/router/localisedIdentity.test.tsx',
35
- 'tests/router/packageSurface.test.ts',
36
- 'tests/router/preloadRedirect.test.ts',
37
- 'tests/router/register.test.ts',
38
33
  'tests/router/routeHooks.test.ts',
39
34
  'tests/router/serverPlugin.test.ts',
40
35
  'tests/router/rscDecoderSecurity.test.ts',
41
- 'tests/router/rscPayloadRouterMatrix.test.ts',
42
36
  'tests/router/rsc.test.tsx',
43
37
  'tests/router/slotUsageSanitizer.test.ts',
44
38
  'tests/router/ssrPreload.test.ts',
@@ -47,27 +41,12 @@ export default {
47
41
  ],
48
42
  extends: commonConfig,
49
43
  }),
50
- withTestPreset({
51
- name: 'plugin-tanstack-router-compatibility',
52
- testEnvironment: 'node',
53
- include: ['tests/router/routerCompatibility.test.ts'],
54
- resolve: {
55
- alias: {
56
- '@modern-js/runtime/router/internal': path.resolve(
57
- __dirname,
58
- 'tests/router/fixtures/legacyRuntimeRouter.ts',
59
- ),
60
- },
61
- },
62
- extends: commonConfig,
63
- }),
64
44
  withTestPreset({
65
45
  name: 'plugin-tanstack-client',
66
46
  testEnvironment: 'happy-dom',
67
47
  include: [
68
48
  'tests/router/clientHydration.test.tsx',
69
49
  'tests/router/dataMutation.test.tsx',
70
- 'tests/router/hydrationBoundary.test.tsx',
71
50
  'tests/router/prefetchLink.test.tsx',
72
51
  'tests/router/prefetchLinkPreload.test.tsx',
73
52
  ],
package/src/cli/index.ts CHANGED
@@ -132,6 +132,16 @@ export function tanstackRouterPlugin(
132
132
  name: '@modern-js/plugin-tanstack',
133
133
  required: ['@modern-js/runtime'],
134
134
  setup: api => {
135
+ const { srcDirectory, serverCompileExcludedFiles = [] } =
136
+ api.getAppContext();
137
+ api.updateAppContext({
138
+ serverCompileExcludedFiles: [
139
+ ...new Set([
140
+ ...serverCompileExcludedFiles,
141
+ path.join(srcDirectory, generatedDirName, 'register.gen.d.ts'),
142
+ ]),
143
+ ],
144
+ });
135
145
  const nestedRoutesForServer: Record<string, unknown> = {};
136
146
 
137
147
  const isTanstackEntrypoint = (entrypoint: Entrypoint) => {
@@ -1,9 +1,21 @@
1
1
  /**
2
- * The router runtime state helpers are owned by @modern-js/runtime (the same
2
+ * The router runtime state helpers are owned by @modern-js/runtime-extensions (the same
3
3
  * implementation backs the built-in react-router provider and the SSR
4
4
  * pipeline). This module only re-exports them so every router provider
5
5
  * writes to the exact same runtime-context extension slot.
6
6
  */
7
+
8
+ import type { RouterLifecycleContext as NativeRouterLifecycleContext } from '@modern-js/runtime/context';
9
+ import type {
10
+ InternalRouterServerSnapshot,
11
+ RouterRouteMatchSnapshot,
12
+ } from '@modern-js/runtime-extensions/router-state';
13
+
14
+ export type RouterLifecycleContext = NativeRouterLifecycleContext & {
15
+ matches?: RouterRouteMatchSnapshot[];
16
+ cleanup?: () => void | Promise<void>;
17
+ serverSnapshot?: InternalRouterServerSnapshot;
18
+ };
7
19
  export {
8
20
  applyRouterRuntimeState,
9
21
  applyRouterServerPrepareResult,
@@ -11,6 +23,5 @@ export {
11
23
  createRouterServerSnapshot,
12
24
  getRouterRuntimeState,
13
25
  getRouterServerSnapshot,
14
- type RouterLifecycleContext,
15
26
  type RouterLifecyclePhase,
16
- } from '@modern-js/runtime/context';
27
+ } from '@modern-js/runtime-extensions/router-state';
@@ -1,10 +1,10 @@
1
1
  // @effect-diagnostics asyncFunction:off newPromise:off strictBooleanExpressions:off unnecessaryArrowBlock:off
2
2
  import {
3
3
  getGlobalEnableRsc,
4
- type InternalRouterServerSnapshot,
5
4
  InternalRuntimeContext,
6
5
  type TInternalRuntimeContext,
7
6
  } from '@modern-js/runtime/context';
7
+ import type { InternalRouterServerSnapshot } from '@modern-js/runtime-extensions/router-state';
8
8
  import {
9
9
  createRequestContext,
10
10
  type RequestContext,
@@ -1,3 +1,4 @@
1
+ import { resolvePreloadFromPrefetch } from '@modern-js/runtime-extensions';
1
2
  import {
2
3
  type AnyRouter,
3
4
  type LinkComponentProps,
@@ -8,29 +9,6 @@ import type { AnchorHTMLAttributes, ReactElement, ReactNode, Ref } from 'react';
8
9
 
9
10
  export type PrefetchBehavior = 'intent' | 'render' | 'viewport' | 'none';
10
11
 
11
- function resolvePreloadFromPrefetch(
12
- prefetch: PrefetchBehavior | undefined,
13
- preload: unknown,
14
- ) {
15
- if (typeof preload !== 'undefined') {
16
- return preload;
17
- }
18
-
19
- if (prefetch === 'none') {
20
- return false;
21
- }
22
-
23
- if (
24
- prefetch === 'intent' ||
25
- prefetch === 'render' ||
26
- prefetch === 'viewport'
27
- ) {
28
- return prefetch;
29
- }
30
-
31
- return 'viewport';
32
- }
33
-
34
12
  export type LinkProps<
35
13
  TRouter extends AnyRouter = RegisteredRouter,
36
14
  TFrom extends string = string,
@@ -1,16 +1,7 @@
1
- /**
2
- * Registers TanStack in the @modern-js/runtime compatibility registry.
3
- * Runtime entries bind the exported local factory into their own provider
4
- * realm; registration remains for older runtime wrappers and mixed cohorts.
5
- *
6
- * This module is intentionally side-effectful (see `sideEffects` in
7
- * package.json).
8
- */
9
1
  import {
10
2
  type RouterProviderFactory,
11
3
  type RouterProviderPlugin,
12
- registerRouterProvider,
13
- } from '@modern-js/runtime/context';
4
+ } from '@modern-js/runtime-extensions/router-provider';
14
5
  import { tanstackRouterPlugin } from './plugin';
15
6
 
16
7
  // TanStack runtime plugin types its API against its own hook registry,
@@ -22,5 +13,3 @@ import { tanstackRouterPlugin } from './plugin';
22
13
  export const tanstackRouterProviderFactory: RouterProviderFactory =
23
14
  userConfig =>
24
15
  tanstackRouterPlugin(userConfig) as unknown as RouterProviderPlugin;
25
-
26
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);