@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.9 → 3.2.0-ultramodern.91

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 (48) hide show
  1. package/dist/cjs/cli/index.js +12 -0
  2. package/dist/cjs/cli/routeSplitting.js +83 -0
  3. package/dist/cjs/cli/tanstackTypes.js +146 -58
  4. package/dist/cjs/runtime/index.js +38 -6
  5. package/dist/cjs/runtime/plugin.js +6 -5
  6. package/dist/cjs/runtime/plugin.node.js +27 -10
  7. package/dist/cjs/runtime/plugin.worker.js +49 -0
  8. package/dist/cjs/runtime/routeTree.js +55 -4
  9. package/dist/cjs/runtime/types.js +27 -1
  10. package/dist/esm/cli/index.mjs +4 -1
  11. package/dist/esm/cli/routeSplitting.mjs +43 -0
  12. package/dist/esm/cli/tanstackTypes.mjs +146 -58
  13. package/dist/esm/runtime/index.mjs +2 -1
  14. package/dist/esm/runtime/plugin.mjs +10 -9
  15. package/dist/esm/runtime/plugin.node.mjs +28 -11
  16. package/dist/esm/runtime/plugin.worker.mjs +1 -0
  17. package/dist/esm/runtime/routeTree.mjs +55 -4
  18. package/dist/esm/runtime/types.mjs +7 -0
  19. package/dist/esm-node/cli/index.mjs +4 -1
  20. package/dist/esm-node/cli/routeSplitting.mjs +44 -0
  21. package/dist/esm-node/cli/tanstackTypes.mjs +146 -58
  22. package/dist/esm-node/runtime/index.mjs +2 -1
  23. package/dist/esm-node/runtime/plugin.mjs +10 -9
  24. package/dist/esm-node/runtime/plugin.node.mjs +28 -11
  25. package/dist/esm-node/runtime/plugin.worker.mjs +2 -0
  26. package/dist/esm-node/runtime/routeTree.mjs +55 -4
  27. package/dist/esm-node/runtime/types.mjs +7 -0
  28. package/dist/types/cli/index.d.ts +4 -0
  29. package/dist/types/cli/routeSplitting.d.ts +29 -0
  30. package/dist/types/runtime/index.d.ts +3 -1
  31. package/dist/types/runtime/plugin.d.ts +1 -1
  32. package/dist/types/runtime/plugin.node.d.ts +1 -1
  33. package/dist/types/runtime/plugin.worker.d.ts +1 -0
  34. package/dist/types/runtime/types.d.ts +7 -0
  35. package/package.json +14 -14
  36. package/src/cli/index.ts +17 -0
  37. package/src/cli/routeSplitting.ts +81 -0
  38. package/src/cli/tanstackTypes.ts +216 -67
  39. package/src/runtime/index.tsx +13 -1
  40. package/src/runtime/plugin.node.tsx +54 -7
  41. package/src/runtime/plugin.tsx +8 -5
  42. package/src/runtime/plugin.worker.tsx +4 -0
  43. package/src/runtime/routeTree.ts +125 -8
  44. package/src/runtime/types.ts +13 -0
  45. package/tests/router/cli.test.ts +239 -0
  46. package/tests/router/fastDefaults.test.ts +25 -0
  47. package/tests/router/routeTree.test.ts +193 -1
  48. package/tests/router/tanstackTypes.test.ts +184 -0
@@ -1 +1,8 @@
1
1
  import "node:module";
2
+ const modernTanstackRouterFastDefaults = {
3
+ defaultStructuralSharing: true
4
+ };
5
+ const getModernTanstackRouterFastDefaults = (config = {})=>({
6
+ defaultStructuralSharing: config.defaultStructuralSharing ?? modernTanstackRouterFastDefaults.defaultStructuralSharing
7
+ });
8
+ export { getModernTanstackRouterFastDefaults, modernTanstackRouterFastDefaults };
@@ -1,9 +1,13 @@
1
1
  import type { AppTools, AppToolsContext, CliPlugin } from '@modern-js/app-tools';
2
2
  import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
3
+ import { type TanstackRouteCodeSplittingOption } from './routeSplitting';
4
+ export type { TanstackRouteCodeSplittingOption, TanstackRsbuildRouteSplittingProfile, } from './routeSplitting';
5
+ export { createTanstackRsbuildRouteSplittingProfile, isTanstackStartRouteModuleSource, resolveTanstackRouteCodeSplittingEnabled, } from './routeSplitting';
3
6
  export { generateTanstackRouterTypesSourceForEntry, isTanstackRouterFrameworkEnabled, } from './tanstackTypes';
4
7
  export type TanstackRouterPluginOptions = {
5
8
  routesDir?: string;
6
9
  generatedDirName?: string;
10
+ routeCodeSplitting?: TanstackRouteCodeSplittingOption;
7
11
  };
8
12
  export declare function writeTanstackRegisterFile(opts: {
9
13
  entries: string[];
@@ -0,0 +1,29 @@
1
+ export type TanstackRouteCodeSplittingOption = boolean | {
2
+ enabled?: boolean;
3
+ };
4
+ export type TanstackRsbuildRouteSplittingProfile = {
5
+ defaultConfig: {
6
+ output: {
7
+ splitRouteChunks: boolean;
8
+ };
9
+ };
10
+ modernRouteChunks: {
11
+ enabled: boolean;
12
+ owner: 'modern';
13
+ };
14
+ builderChunkSplit: {
15
+ owner: 'modern-rsbuild';
16
+ preserved: true;
17
+ };
18
+ tanstackStartRspackSplitter: {
19
+ compatible: boolean;
20
+ reason: string;
21
+ clientDeleteNodes: string[];
22
+ routeFactoryCalls: string[];
23
+ };
24
+ };
25
+ export declare function isTanstackStartRouteModuleSource(source: string): boolean;
26
+ export declare function resolveTanstackRouteCodeSplittingEnabled(option?: TanstackRouteCodeSplittingOption): boolean;
27
+ export declare function createTanstackRsbuildRouteSplittingProfile(opts: {
28
+ routeCodeSplitting?: TanstackRouteCodeSplittingOption;
29
+ }): TanstackRsbuildRouteSplittingProfile;
@@ -1,5 +1,5 @@
1
1
  export * from '@tanstack/react-router';
2
- export { useMatch } from '@tanstack/react-router';
2
+ export { Outlet, useLocation, useMatch, useMatches, useNavigate, useRouter, } from '@tanstack/react-router';
3
3
  export type { Fetcher, FetcherState, FetcherSubmitOptions, FormProps, SubmitOptions, } from './dataMutation';
4
4
  export { Form, RouteActionResponseError, useFetcher, } from './dataMutation';
5
5
  export { tanstackRouterPlugin, tanstackRouterPlugin as default, } from './plugin';
@@ -7,3 +7,5 @@ export type { LinkProps, NavLinkProps, PrefetchBehavior, } from './prefetchLink'
7
7
  export { Link, NavLink } from './prefetchLink';
8
8
  export type { AnyCompositeComponent, AnyRenderableServerComponent, CompositeComponentProps, } from './rsc/client';
9
9
  export { CompositeComponent } from './rsc/client';
10
+ export type { RouterConfig } from './types';
11
+ export { getModernTanstackRouterFastDefaults, modernTanstackRouterFastDefaults, } from './types';
@@ -2,7 +2,7 @@ import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
2
2
  import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
3
3
  import { type TInternalRuntimeContext } from '@modern-js/runtime/context';
4
4
  import { type RouterExtendsHooks } from './hooks';
5
- import type { RouterConfig } from './types';
5
+ import { type RouterConfig } from './types';
6
6
  type TanstackRouterRuntimeConfig = {
7
7
  plugins?: TanstackRouterRuntimePlugin[];
8
8
  router?: Partial<RouterConfig>;
@@ -2,7 +2,7 @@ import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
2
2
  import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
3
3
  import { type TInternalRuntimeContext } from '@modern-js/runtime/context';
4
4
  import { type RouterExtendsHooks } from './hooks';
5
- import type { RouterConfig } from './types';
5
+ import { type RouterConfig } from './types';
6
6
  type TanstackRouterRuntimeConfig = {
7
7
  plugins?: TanstackRouterRuntimePlugin[];
8
8
  router?: Partial<RouterConfig>;
@@ -0,0 +1 @@
1
+ export { default, tanstackRouterPlugin, } from './plugin.node';
@@ -18,8 +18,15 @@ export type RouterConfig = {
18
18
  future?: Partial<{
19
19
  v7_startTransition: boolean;
20
20
  }>;
21
+ defaultStructuralSharing?: boolean;
21
22
  unstable_reloadOnURLMismatch?: boolean;
22
23
  };
24
+ export declare const modernTanstackRouterFastDefaults: {
25
+ readonly defaultStructuralSharing: true;
26
+ };
27
+ export declare const getModernTanstackRouterFastDefaults: (config?: Partial<Pick<RouterConfig, 'defaultStructuralSharing'>>) => {
28
+ defaultStructuralSharing: boolean;
29
+ };
23
30
  export interface RouterRouteMatchSnapshot {
24
31
  routeId: string;
25
32
  assetRouteId?: string;
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.2.0-ultramodern.9",
21
+ "version": "3.2.0-ultramodern.91",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -85,16 +85,16 @@
85
85
  }
86
86
  },
87
87
  "dependencies": {
88
- "@swc/helpers": "^0.5.21",
89
- "@tanstack/react-router": "1.170.1",
90
- "@tanstack/router-core": "1.170.1",
91
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.9",
92
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.9",
93
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.9",
94
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.9"
88
+ "@swc/helpers": "^0.5.23",
89
+ "@tanstack/react-router": "1.170.11",
90
+ "@tanstack/router-core": "1.171.9",
91
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.91",
92
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.91",
93
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.91",
94
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.91"
95
95
  },
96
96
  "peerDependencies": {
97
- "@modern-js/runtime": "3.2.0-ultramodern.9",
97
+ "@modern-js/runtime": "3.2.0-ultramodern.91",
98
98
  "react": "^19.2.6",
99
99
  "react-dom": "^19.2.6"
100
100
  },
@@ -103,14 +103,14 @@
103
103
  "@tanstack/history": "1.162.0",
104
104
  "@testing-library/dom": "^10.4.1",
105
105
  "@testing-library/react": "^16.3.2",
106
- "@types/node": "^25.8.0",
107
- "@types/react": "^19.2.14",
106
+ "@types/node": "^25.9.1",
107
+ "@types/react": "^19.2.15",
108
108
  "@types/react-dom": "^19.2.3",
109
- "@typescript/native-preview": "7.0.0-dev.20260516.1",
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/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.9",
113
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.9",
112
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.91",
113
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.91",
114
114
  "@scripts/rstest-config": "2.66.0"
115
115
  },
116
116
  "sideEffects": false,
package/src/cli/index.ts CHANGED
@@ -18,11 +18,24 @@ import {
18
18
  fs,
19
19
  NESTED_ROUTE_SPEC_FILE,
20
20
  } from '@modern-js/utils';
21
+ import {
22
+ createTanstackRsbuildRouteSplittingProfile,
23
+ type TanstackRouteCodeSplittingOption,
24
+ } from './routeSplitting';
21
25
  import {
22
26
  generateTanstackRouterTypesSourceForEntry,
23
27
  isTanstackRouterFrameworkEnabled,
24
28
  } from './tanstackTypes';
25
29
 
30
+ export type {
31
+ TanstackRouteCodeSplittingOption,
32
+ TanstackRsbuildRouteSplittingProfile,
33
+ } from './routeSplitting';
34
+ export {
35
+ createTanstackRsbuildRouteSplittingProfile,
36
+ isTanstackStartRouteModuleSource,
37
+ resolveTanstackRouteCodeSplittingEnabled,
38
+ } from './routeSplitting';
26
39
  export {
27
40
  generateTanstackRouterTypesSourceForEntry,
28
41
  isTanstackRouterFrameworkEnabled,
@@ -35,6 +48,7 @@ const ENTRYPOINTS_KEY = '@modern-js/plugin-tanstack';
35
48
  export type TanstackRouterPluginOptions = {
36
49
  routesDir?: string;
37
50
  generatedDirName?: string;
51
+ routeCodeSplitting?: TanstackRouteCodeSplittingOption;
38
52
  };
39
53
 
40
54
  type RuntimeRouterCliHelpers = {
@@ -224,6 +238,8 @@ export function tanstackRouterPlugin(
224
238
  const routesDir = options.routesDir || DEFAULT_ROUTES_DIR;
225
239
  const generatedDirName =
226
240
  options.generatedDirName || DEFAULT_GENERATED_DIR_NAME;
241
+ const routeSplittingProfile =
242
+ createTanstackRsbuildRouteSplittingProfile(options);
227
243
 
228
244
  return {
229
245
  name: '@modern-js/plugin-tanstack',
@@ -265,6 +281,7 @@ export function tanstackRouterPlugin(
265
281
  }));
266
282
 
267
283
  api.config(() => ({
284
+ ...routeSplittingProfile.defaultConfig,
268
285
  source: {
269
286
  include: [
270
287
  /[\\/]node_modules[\\/]@tanstack[\\/]react-router[\\/]/,
@@ -0,0 +1,81 @@
1
+ export type TanstackRouteCodeSplittingOption =
2
+ | boolean
3
+ | {
4
+ enabled?: boolean;
5
+ };
6
+
7
+ export type TanstackRsbuildRouteSplittingProfile = {
8
+ defaultConfig: {
9
+ output: {
10
+ splitRouteChunks: boolean;
11
+ };
12
+ };
13
+ modernRouteChunks: {
14
+ enabled: boolean;
15
+ owner: 'modern';
16
+ };
17
+ builderChunkSplit: {
18
+ owner: 'modern-rsbuild';
19
+ preserved: true;
20
+ };
21
+ tanstackStartRspackSplitter: {
22
+ compatible: boolean;
23
+ reason: string;
24
+ clientDeleteNodes: string[];
25
+ routeFactoryCalls: string[];
26
+ };
27
+ };
28
+
29
+ const TANSTACK_START_ROUTE_FACTORY_CALLS = [
30
+ 'createFileRoute',
31
+ 'createRootRoute',
32
+ 'createRootRouteWithContext',
33
+ ] as const;
34
+
35
+ const TANSTACK_START_ROUTE_FACTORY_REGEX =
36
+ /\b(createFileRoute|createRootRoute|createRootRouteWithContext)\s*(?:<|\()/;
37
+
38
+ export function isTanstackStartRouteModuleSource(source: string) {
39
+ return TANSTACK_START_ROUTE_FACTORY_REGEX.test(source);
40
+ }
41
+
42
+ export function resolveTanstackRouteCodeSplittingEnabled(
43
+ option?: TanstackRouteCodeSplittingOption,
44
+ ) {
45
+ if (typeof option === 'boolean') {
46
+ return option;
47
+ }
48
+
49
+ return option?.enabled ?? true;
50
+ }
51
+
52
+ export function createTanstackRsbuildRouteSplittingProfile(opts: {
53
+ routeCodeSplitting?: TanstackRouteCodeSplittingOption;
54
+ }): TanstackRsbuildRouteSplittingProfile {
55
+ return {
56
+ defaultConfig: {
57
+ output: {
58
+ splitRouteChunks: resolveTanstackRouteCodeSplittingEnabled(
59
+ opts.routeCodeSplitting,
60
+ ),
61
+ },
62
+ },
63
+ modernRouteChunks: {
64
+ enabled: resolveTanstackRouteCodeSplittingEnabled(
65
+ opts.routeCodeSplitting,
66
+ ),
67
+ owner: 'modern',
68
+ },
69
+ builderChunkSplit: {
70
+ owner: 'modern-rsbuild',
71
+ preserved: true,
72
+ },
73
+ tanstackStartRspackSplitter: {
74
+ compatible: false,
75
+ reason:
76
+ 'TanStack Start Rsbuild route splitting is tied to TanStack file-route factory modules; Modern generates TanStack route trees from Modern route metadata and owns route chunking through output.splitRouteChunks.',
77
+ clientDeleteNodes: ['ssr', 'server', 'headers'],
78
+ routeFactoryCalls: [...TANSTACK_START_ROUTE_FACTORY_CALLS],
79
+ },
80
+ };
81
+ }