@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.3 → 3.5.0-ultramodern.31
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.
- package/dist/cjs/cli/artifacts.js +157 -0
- package/dist/cjs/cli/index.js +8 -79
- package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +113 -0
- package/dist/cjs/cli/tanstackTypes/shared.js +130 -0
- package/dist/cjs/cli/tanstackTypes/source.js +251 -0
- package/dist/cjs/cli/tanstackTypes.js +4 -350
- package/dist/cjs/runtime/blockingSubscribe.js +64 -0
- package/dist/cjs/runtime/{pluginCore.js → clientBasepath.js} +12 -19
- package/dist/cjs/runtime/clientHydration.js +129 -0
- package/dist/cjs/runtime/dataMutation.js +11 -176
- package/dist/cjs/runtime/formData.js +116 -0
- package/dist/cjs/runtime/loaderBridge.js +4 -1
- package/dist/cjs/runtime/plugin.js +21 -125
- package/dist/cjs/runtime/plugin.node.js +45 -125
- package/dist/cjs/runtime/pluginShared.js +90 -0
- package/dist/cjs/runtime/prefetchLink.js +15 -2
- package/dist/cjs/runtime/routeTree/components.js +102 -0
- package/dist/cjs/runtime/routeTree/construction.js +152 -0
- package/dist/cjs/runtime/routeTree/index.js +47 -0
- package/dist/cjs/runtime/routeTree/loaders.js +158 -0
- package/dist/cjs/runtime/routeTree/paths.js +57 -0
- package/dist/cjs/runtime/routeTree/staticData.js +63 -0
- package/dist/cjs/runtime/routeTree/tanstackRoutes.js +57 -0
- package/dist/cjs/runtime/routeTree/types.js +18 -0
- package/dist/cjs/runtime/routeTree.js +7 -320
- package/dist/cjs/runtime/rsc/CompositeComponent.js +18 -13
- package/dist/cjs/runtime/rsc/RscNodeRenderer.js +5 -16
- package/dist/cjs/runtime/rsc/client.js +8 -25
- package/dist/cjs/runtime/rsc/flightSerialization.js +132 -0
- package/dist/cjs/runtime/rsc/payloadErrors.js +99 -0
- package/dist/cjs/runtime/rsc/payloadFetch.js +117 -0
- package/dist/cjs/runtime/rsc/payloadRouter.js +21 -142
- package/dist/cjs/runtime/rsc/payloadRoutes.js +106 -0
- package/dist/cjs/runtime/rsc/payloadStorage.js +58 -0
- package/dist/cjs/runtime/rsc/server.js +14 -18
- package/dist/cjs/runtime/rsc/shared.js +71 -0
- package/dist/cjs/runtime/rsc/treeGetter.js +72 -0
- package/dist/cjs/runtime/ssrManagedTags.js +103 -0
- package/dist/cjs/runtime/ssrPreload.js +89 -0
- package/dist/cjs/runtime/ssrTypes.js +18 -0
- package/dist/cjs/runtime/submitAction.js +161 -0
- package/dist/cjs/runtime/utils.js +49 -86
- package/dist/esm/cli/artifacts.mjs +103 -0
- package/dist/esm/cli/index.mjs +4 -78
- package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +75 -0
- package/dist/esm/cli/tanstackTypes/shared.mjs +68 -0
- package/dist/esm/cli/tanstackTypes/source.mjs +203 -0
- package/dist/esm/cli/tanstackTypes.mjs +2 -339
- package/dist/esm/runtime/blockingSubscribe.mjs +19 -0
- package/dist/esm/runtime/clientBasepath.mjs +10 -0
- package/dist/esm/runtime/clientHydration.mjs +70 -0
- package/dist/esm/runtime/dataMutation.mjs +2 -167
- package/dist/esm/runtime/formData.mjs +63 -0
- package/dist/esm/runtime/loaderBridge.mjs +4 -1
- package/dist/esm/runtime/plugin.mjs +14 -118
- package/dist/esm/runtime/plugin.node.mjs +41 -121
- package/dist/esm/runtime/pluginShared.mjs +40 -0
- package/dist/esm/runtime/prefetchLink.mjs +18 -5
- package/dist/esm/runtime/routeTree/components.mjs +55 -0
- package/dist/esm/runtime/routeTree/construction.mjs +111 -0
- package/dist/esm/runtime/routeTree/index.mjs +2 -0
- package/dist/esm/runtime/routeTree/loaders.mjs +117 -0
- package/dist/esm/runtime/routeTree/paths.mjs +16 -0
- package/dist/esm/runtime/routeTree/staticData.mjs +22 -0
- package/dist/esm/runtime/routeTree/tanstackRoutes.mjs +13 -0
- package/dist/esm/runtime/routeTree/types.mjs +0 -0
- package/dist/esm/runtime/routeTree.mjs +1 -318
- package/dist/esm/runtime/rsc/CompositeComponent.mjs +18 -13
- package/dist/esm/runtime/rsc/RscNodeRenderer.mjs +4 -15
- package/dist/esm/runtime/rsc/client.mjs +6 -26
- package/dist/esm/runtime/rsc/flightSerialization.mjs +88 -0
- package/dist/esm/runtime/rsc/payloadErrors.mjs +49 -0
- package/dist/esm/runtime/rsc/payloadFetch.mjs +61 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +12 -133
- package/dist/esm/runtime/rsc/payloadRoutes.mjs +50 -0
- package/dist/esm/runtime/rsc/payloadStorage.mjs +14 -0
- package/dist/esm/runtime/rsc/server.mjs +17 -21
- package/dist/esm/runtime/rsc/shared.mjs +21 -0
- package/dist/esm/runtime/rsc/treeGetter.mjs +34 -0
- package/dist/esm/runtime/ssrManagedTags.mjs +53 -0
- package/dist/esm/runtime/ssrPreload.mjs +51 -0
- package/dist/esm/runtime/ssrTypes.mjs +0 -0
- package/dist/esm/runtime/submitAction.mjs +120 -0
- package/dist/esm/runtime/utils.mjs +47 -75
- package/dist/esm-node/cli/artifacts.mjs +104 -0
- package/dist/esm-node/cli/index.mjs +4 -78
- package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +76 -0
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +69 -0
- package/dist/esm-node/cli/tanstackTypes/source.mjs +204 -0
- package/dist/esm-node/cli/tanstackTypes.mjs +2 -339
- package/dist/esm-node/runtime/blockingSubscribe.mjs +20 -0
- package/dist/esm-node/runtime/clientBasepath.mjs +11 -0
- package/dist/esm-node/runtime/clientHydration.mjs +71 -0
- package/dist/esm-node/runtime/dataMutation.mjs +2 -167
- package/dist/esm-node/runtime/formData.mjs +64 -0
- package/dist/esm-node/runtime/loaderBridge.mjs +4 -1
- package/dist/esm-node/runtime/plugin.mjs +14 -118
- package/dist/esm-node/runtime/plugin.node.mjs +41 -121
- package/dist/esm-node/runtime/pluginShared.mjs +41 -0
- package/dist/esm-node/runtime/prefetchLink.mjs +18 -5
- package/dist/esm-node/runtime/routeTree/components.mjs +56 -0
- package/dist/esm-node/runtime/routeTree/construction.mjs +112 -0
- package/dist/esm-node/runtime/routeTree/index.mjs +3 -0
- package/dist/esm-node/runtime/routeTree/loaders.mjs +118 -0
- package/dist/esm-node/runtime/routeTree/paths.mjs +17 -0
- package/dist/esm-node/runtime/routeTree/staticData.mjs +23 -0
- package/dist/esm-node/runtime/routeTree/tanstackRoutes.mjs +14 -0
- package/dist/esm-node/runtime/routeTree/types.mjs +1 -0
- package/dist/esm-node/runtime/routeTree.mjs +1 -318
- package/dist/esm-node/runtime/rsc/CompositeComponent.mjs +18 -13
- package/dist/esm-node/runtime/rsc/RscNodeRenderer.mjs +4 -15
- package/dist/esm-node/runtime/rsc/client.mjs +6 -26
- package/dist/esm-node/runtime/rsc/flightSerialization.mjs +89 -0
- package/dist/esm-node/runtime/rsc/payloadErrors.mjs +50 -0
- package/dist/esm-node/runtime/rsc/payloadFetch.mjs +62 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +12 -133
- package/dist/esm-node/runtime/rsc/payloadRoutes.mjs +51 -0
- package/dist/esm-node/runtime/rsc/payloadStorage.mjs +15 -0
- package/dist/esm-node/runtime/rsc/server.mjs +17 -21
- package/dist/esm-node/runtime/rsc/shared.mjs +22 -0
- package/dist/esm-node/runtime/rsc/treeGetter.mjs +35 -0
- package/dist/esm-node/runtime/ssrManagedTags.mjs +54 -0
- package/dist/esm-node/runtime/ssrPreload.mjs +52 -0
- package/dist/esm-node/runtime/ssrTypes.mjs +1 -0
- package/dist/esm-node/runtime/submitAction.mjs +121 -0
- package/dist/esm-node/runtime/utils.mjs +47 -75
- package/dist/types/cli/artifacts.d.ts +33 -0
- package/dist/types/cli/index.d.ts +2 -22
- package/dist/types/cli/tanstackTypes/canonicalRoutes.d.ts +22 -0
- package/dist/types/cli/tanstackTypes/shared.d.ts +20 -0
- package/dist/types/cli/tanstackTypes/source.d.ts +10 -0
- package/dist/types/cli/tanstackTypes.d.ts +3 -31
- package/dist/types/runtime/blockingSubscribe.d.ts +3 -0
- package/dist/types/runtime/clientBasepath.d.ts +1 -0
- package/dist/types/runtime/clientHydration.d.ts +19 -0
- package/dist/types/runtime/dataMutation.d.ts +3 -12
- package/dist/types/runtime/formData.d.ts +23 -0
- package/dist/types/runtime/plugin.d.ts +1 -1
- package/dist/types/runtime/plugin.node.d.ts +1 -1
- package/dist/types/runtime/pluginShared.d.ts +39 -0
- package/dist/types/runtime/routeTree/components.d.ts +7 -0
- package/dist/types/runtime/routeTree/construction.d.ts +5 -0
- package/dist/types/runtime/routeTree/index.d.ts +2 -0
- package/dist/types/runtime/routeTree/loaders.d.ts +4 -0
- package/dist/types/runtime/routeTree/paths.d.ts +3 -0
- package/dist/types/runtime/routeTree/staticData.d.ts +19 -0
- package/dist/types/runtime/routeTree/tanstackRoutes.d.ts +4 -0
- package/dist/types/runtime/routeTree/types.d.ts +75 -0
- package/dist/types/runtime/routeTree.d.ts +1 -9
- package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -2
- package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +2 -3
- package/dist/types/runtime/rsc/client.d.ts +2 -0
- package/dist/types/runtime/rsc/flightSerialization.d.ts +3 -0
- package/dist/types/runtime/rsc/payloadErrors.d.ts +6 -0
- package/dist/types/runtime/rsc/payloadFetch.d.ts +10 -0
- package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -10
- package/dist/types/runtime/rsc/payloadRoutes.d.ts +43 -0
- package/dist/types/runtime/rsc/payloadStorage.d.ts +5 -0
- package/dist/types/runtime/rsc/shared.d.ts +19 -0
- package/dist/types/runtime/rsc/treeGetter.d.ts +1 -0
- package/dist/types/runtime/ssrManagedTags.d.ts +7 -0
- package/dist/types/runtime/ssrPreload.d.ts +2 -0
- package/dist/types/runtime/ssrTypes.d.ts +43 -0
- package/dist/types/runtime/state.d.ts +1 -1
- package/dist/types/runtime/submitAction.d.ts +14 -0
- package/dist/types/runtime/types.d.ts +4 -9
- package/dist/types/runtime/utils.d.ts +4 -24
- package/package.json +30 -8
- package/rstest.config.mts +3 -0
- package/src/cli/artifacts.ts +255 -0
- package/src/cli/index.ts +7 -185
- package/src/cli/tanstackTypes/canonicalRoutes.ts +157 -0
- package/src/cli/tanstackTypes/shared.ts +119 -0
- package/src/cli/tanstackTypes/source.ts +405 -0
- package/src/cli/tanstackTypes.ts +4 -647
- package/src/runtime/blockingSubscribe.ts +48 -0
- package/src/runtime/clientBasepath.ts +12 -0
- package/src/runtime/clientHydration.ts +151 -0
- package/src/runtime/dataMutation.tsx +9 -306
- package/src/runtime/formData.ts +153 -0
- package/src/runtime/loaderBridge.ts +8 -3
- package/src/runtime/plugin.node.tsx +76 -291
- package/src/runtime/plugin.tsx +21 -257
- package/src/runtime/pluginShared.ts +112 -0
- package/src/runtime/prefetchLink.tsx +78 -15
- package/src/runtime/routeTree/components.ts +130 -0
- package/src/runtime/routeTree/construction.ts +238 -0
- package/src/runtime/routeTree/index.ts +7 -0
- package/src/runtime/routeTree/loaders.ts +232 -0
- package/src/runtime/routeTree/paths.ts +36 -0
- package/src/runtime/routeTree/staticData.ts +66 -0
- package/src/runtime/routeTree/tanstackRoutes.ts +36 -0
- package/src/runtime/routeTree/types.ts +87 -0
- package/src/runtime/routeTree.ts +5 -750
- package/src/runtime/rsc/CompositeComponent.tsx +29 -20
- package/src/runtime/rsc/RscNodeRenderer.tsx +9 -27
- package/src/runtime/rsc/client.tsx +12 -40
- package/src/runtime/rsc/flightSerialization.ts +158 -0
- package/src/runtime/rsc/payloadErrors.ts +73 -0
- package/src/runtime/rsc/payloadFetch.ts +97 -0
- package/src/runtime/rsc/payloadRouter.ts +29 -234
- package/src/runtime/rsc/payloadRoutes.ts +122 -0
- package/src/runtime/rsc/payloadStorage.ts +35 -0
- package/src/runtime/rsc/server.tsx +20 -29
- package/src/runtime/rsc/shared.ts +70 -0
- package/src/runtime/rsc/treeGetter.tsx +52 -0
- package/src/runtime/ssrManagedTags.ts +107 -0
- package/src/runtime/ssrPreload.ts +125 -0
- package/src/runtime/ssrTypes.ts +51 -0
- package/src/runtime/state.ts +4 -2
- package/src/runtime/submitAction.ts +194 -0
- package/src/runtime/types.ts +6 -13
- package/src/runtime/utils.tsx +76 -110
- package/src/types/react-server-dom-rspack.d.ts +56 -0
- package/tests/castRatchet.test.ts +85 -0
- package/tests/router/cli.test.ts +7 -0
- package/tests/router/dataMutation.test.tsx +59 -0
- package/tests/router/fixtures/router-gen.golden.txt +72 -0
- package/tests/router/generateRouteArtifacts.test.ts +106 -0
- package/tests/router/loaderBridge.test.ts +21 -0
- package/tests/router/prefetchLink.test.tsx +106 -59
- package/tests/router/prefetchLinkPreload.test.tsx +85 -0
- package/tests/router/routeTree.test.ts +46 -11
- package/tests/router/rsc.test.tsx +189 -0
- package/tests/router/ssrPreload.test.ts +30 -0
- package/tests/router/tanstackTypes.test.ts +254 -1
- package/dist/esm/runtime/pluginCore.mjs +0 -14
- package/dist/esm-node/runtime/pluginCore.mjs +0 -15
- package/dist/types/runtime/pluginCore.d.ts +0 -21
- package/src/runtime/pluginCore.ts +0 -48
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { ServerPayload } from '@modern-js/runtime/context';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
state?: {
|
|
5
|
-
location?: unknown;
|
|
6
|
-
matches?: unknown;
|
|
7
|
-
statusCode?: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
2
|
+
import type { TanstackPayloadRouterLike } from './payloadRoutes';
|
|
3
|
+
export { __setTanstackRscPayloadDecoderForTests } from './payloadFetch';
|
|
10
4
|
type LoadRouteDataOptions = {
|
|
11
5
|
hasClientLoader?: boolean;
|
|
12
6
|
loadClientData: () => Promise<unknown>;
|
|
@@ -20,5 +14,3 @@ export declare function handleTanstackRscRedirect(headers: Headers, basename: st
|
|
|
20
14
|
export declare function isTanstackRscPayloadNavigationEnabled(): boolean;
|
|
21
15
|
export declare function loadTanstackRscPayload(request: Request): Promise<ServerPayload>;
|
|
22
16
|
export declare function loadTanstackRscRouteData({ hasClientLoader, loadClientData, request, routeId, }: LoadRouteDataOptions): Promise<unknown>;
|
|
23
|
-
export declare function __setTanstackRscPayloadDecoderForTests(decoder?: PayloadDecoder): void;
|
|
24
|
-
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PayloadRoute, ServerPayload } from '@modern-js/runtime/context';
|
|
2
|
+
export type RouterStaticData = {
|
|
3
|
+
modernRouteAction?: unknown;
|
|
4
|
+
modernRouteHandle?: unknown;
|
|
5
|
+
modernRouteHasAction?: unknown;
|
|
6
|
+
modernRouteHasClientLoader?: unknown;
|
|
7
|
+
modernRouteHasLoader?: unknown;
|
|
8
|
+
modernRouteId?: unknown;
|
|
9
|
+
modernRouteIsClientComponent?: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type RouterRouteLike = {
|
|
12
|
+
id?: unknown;
|
|
13
|
+
options?: {
|
|
14
|
+
index?: unknown;
|
|
15
|
+
path?: unknown;
|
|
16
|
+
staticData?: RouterStaticData;
|
|
17
|
+
};
|
|
18
|
+
parentRoute?: RouterRouteLike;
|
|
19
|
+
};
|
|
20
|
+
export type RouterMatchLike = {
|
|
21
|
+
error?: unknown;
|
|
22
|
+
id?: unknown;
|
|
23
|
+
loaderData?: unknown;
|
|
24
|
+
params?: unknown;
|
|
25
|
+
pathname?: unknown;
|
|
26
|
+
pathnameBase?: unknown;
|
|
27
|
+
route?: RouterRouteLike;
|
|
28
|
+
routeId?: unknown;
|
|
29
|
+
};
|
|
30
|
+
export type TanstackPayloadRouterLike = {
|
|
31
|
+
state?: {
|
|
32
|
+
location?: unknown;
|
|
33
|
+
matches?: unknown;
|
|
34
|
+
statusCode?: unknown;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare function toPlainRecord(value: unknown): Record<string, unknown>;
|
|
38
|
+
export declare function toPlainLocation(location: unknown): ServerPayload['location'];
|
|
39
|
+
export declare function getRouteId(match: RouterMatchLike): string | undefined;
|
|
40
|
+
export declare function getRouteStaticData(match: RouterMatchLike): RouterStaticData;
|
|
41
|
+
export declare function getRouteParentId(match: RouterMatchLike): string | undefined;
|
|
42
|
+
export declare function toRoutePath(match: RouterMatchLike): string | undefined;
|
|
43
|
+
export declare function toPayloadRoute(match: RouterMatchLike): PayloadRoute | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ServerPayload } from '@modern-js/runtime/context';
|
|
2
|
+
import type { TanstackRouterWithServerSsr } from '../ssrTypes';
|
|
3
|
+
export declare const setTanstackRscServerPayload: (payload: ServerPayload) => void;
|
|
4
|
+
export declare const setTanstackRscRouter: (router: TanstackRouterWithServerSsr) => void;
|
|
5
|
+
export declare const getTanstackRscRouter: () => TanstackRouterWithServerSsr | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type AnyCompositeComponent, type AnyRenderableServerComponent, type RscSlotUsageEvent } from './symbols';
|
|
3
|
+
export declare const TANSTACK_RSC_FLIGHT_VALUE = "__modernTanstackRsc";
|
|
4
|
+
export type SerializedTanstackRscFlightValue = {
|
|
5
|
+
[TANSTACK_RSC_FLIGHT_VALUE]: true;
|
|
6
|
+
kind: 'renderable' | 'composite';
|
|
7
|
+
slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
|
|
8
|
+
stream: ReadableStream<Uint8Array>;
|
|
9
|
+
};
|
|
10
|
+
export declare function isSerializedTanstackRscFlightValue(value: unknown): value is SerializedTanstackRscFlightValue;
|
|
11
|
+
export declare function EmptyFallback(): null;
|
|
12
|
+
export declare function selectTreePath(tree: unknown, path: string[]): React.ReactNode;
|
|
13
|
+
type RenderSelectedTreeSource = AnyRenderableServerComponent | AnyCompositeComponent;
|
|
14
|
+
type RenderSelectedTreeOptions = {
|
|
15
|
+
getTree?: (() => unknown) | undefined;
|
|
16
|
+
missingTreeError: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function renderSelectedTree(src: RenderSelectedTreeSource, { getTree, missingTreeError, }: RenderSelectedTreeOptions): React.ReactNode;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createTreeGetterFromFlightStream(stream: ReadableStream<Uint8Array>): () => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyRouter } from '@tanstack/react-router';
|
|
2
|
+
import type { TanstackRouterWithServerSsr } from './ssrTypes';
|
|
3
|
+
export declare function waitForRouterSerialization(tanstackRouter: TanstackRouterWithServerSsr): Promise<void>;
|
|
4
|
+
export declare function routerManagedTagsToHtml(tags: unknown): string[];
|
|
5
|
+
export declare function createGetSsrHref(request: Request): string;
|
|
6
|
+
export declare function collectRouterErrors(tanstackRouter: AnyRouter): Record<string, unknown> | undefined;
|
|
7
|
+
export declare function attachServerSsrUtils(router: TanstackRouterWithServerSsr): Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RequestContext } from '@modern-js/runtime-utils/node';
|
|
2
|
+
import type { AnyRouter } from '@tanstack/react-router';
|
|
3
|
+
export type ModernTanstackRouterContext = {
|
|
4
|
+
request: Request;
|
|
5
|
+
requestContext: RequestContext<Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
export type RouterManagedTag = {
|
|
8
|
+
attrs?: Record<string, unknown>;
|
|
9
|
+
children?: unknown;
|
|
10
|
+
tag?: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type RouterMatchWithError = {
|
|
13
|
+
error?: unknown;
|
|
14
|
+
route?: {
|
|
15
|
+
id?: unknown;
|
|
16
|
+
options?: RouterRouteOptions;
|
|
17
|
+
};
|
|
18
|
+
routeId?: unknown;
|
|
19
|
+
};
|
|
20
|
+
export type RouterRouteOptions = {
|
|
21
|
+
component?: unknown;
|
|
22
|
+
errorComponent?: unknown;
|
|
23
|
+
notFoundComponent?: unknown;
|
|
24
|
+
pendingComponent?: unknown;
|
|
25
|
+
};
|
|
26
|
+
export type RouterRouteWithOptions = {
|
|
27
|
+
options?: RouterRouteOptions;
|
|
28
|
+
};
|
|
29
|
+
export type TanstackRouterWithServerSsr = AnyRouter & {
|
|
30
|
+
resolveRedirect?: (redirect: Response) => Response;
|
|
31
|
+
routesById?: Record<string, RouterRouteWithOptions>;
|
|
32
|
+
serverSsr?: {
|
|
33
|
+
cleanup?: () => void;
|
|
34
|
+
dehydrate?: () => Promise<void> | void;
|
|
35
|
+
isSerializationFinished?: () => boolean;
|
|
36
|
+
onSerializationFinished?: (listener: () => void) => void;
|
|
37
|
+
takeBufferedScripts?: () => unknown;
|
|
38
|
+
};
|
|
39
|
+
state: AnyRouter['state'] & {
|
|
40
|
+
matches?: unknown;
|
|
41
|
+
redirect?: Response;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type InternalRouterRuntimeState } from '@modern-js/runtime/context';
|
|
1
2
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
2
|
-
import type { InternalRouterRuntimeState } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Router runtime state as published by the TanStack router provider into the
|
|
5
5
|
* runtime-context extension slot.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnyRouter } from '@tanstack/react-router';
|
|
2
|
+
import type { SubmitOptions, SubmitTarget } from './formData';
|
|
3
|
+
export declare class RouteActionResponseError<TData = unknown> extends Error {
|
|
4
|
+
readonly response: Response;
|
|
5
|
+
readonly data: TData;
|
|
6
|
+
constructor(response: Response, data: TData);
|
|
7
|
+
}
|
|
8
|
+
export declare function submitRouteAction({ router, target, options, isFetcher, onInvalidateStart, }: {
|
|
9
|
+
router: AnyRouter;
|
|
10
|
+
target: SubmitTarget;
|
|
11
|
+
options?: SubmitOptions;
|
|
12
|
+
isFetcher?: boolean;
|
|
13
|
+
onInvalidateStart?: () => void;
|
|
14
|
+
}): Promise<any>;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import type { RouterFramework } from '@modern-js/runtime/context';
|
|
1
|
+
import type { ModernRoute, RouterFramework } from '@modern-js/runtime/context';
|
|
2
2
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
|
-
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
4
3
|
import type React from 'react';
|
|
5
|
-
export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '@modern-js/runtime/context';
|
|
6
|
-
/**
|
|
7
|
-
* TanStack-specific router config. Unlike the react-router provider config,
|
|
8
|
-
* this intentionally has no `oldVersion`/`future` fields — those are
|
|
9
|
-
* react-router-only knobs with no meaning here.
|
|
10
|
-
*/
|
|
4
|
+
export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, LoaderFunction, LoaderFunctionArgs, ModernRoute, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '@modern-js/runtime/context';
|
|
5
|
+
/** TanStack-specific router config. */
|
|
11
6
|
export type RouterConfig = {
|
|
12
7
|
framework?: RouterFramework;
|
|
13
8
|
routesConfig: {
|
|
14
9
|
globalApp?: React.ComponentType<any>;
|
|
15
|
-
routes?:
|
|
10
|
+
routes?: ModernRoute[];
|
|
16
11
|
};
|
|
17
12
|
serverBase?: string[];
|
|
18
13
|
supportHtml5History?: boolean;
|
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
|
-
import type { NestedRoute, PageRoute, SSRMode } from '@modern-js/types';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import type { ModernRoute } from './types';
|
|
4
|
+
export type SSRMode = 'string' | 'stream';
|
|
4
5
|
type RouterConfig = {
|
|
5
6
|
routesConfig: {
|
|
6
7
|
globalApp?: React.ComponentType<any>;
|
|
7
|
-
routes?:
|
|
8
|
+
routes?: ModernRoute[];
|
|
8
9
|
};
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
Component: React.ComponentType;
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
};
|
|
14
|
-
export type ModernRouteObject = RouteObject & {
|
|
15
|
-
isClientComponent?: boolean;
|
|
16
|
-
hasClientLoader?: boolean;
|
|
17
|
-
hasLoader?: boolean;
|
|
18
|
-
hasAction?: boolean;
|
|
19
|
-
inValidSSRRoute?: boolean;
|
|
20
|
-
lazyImport?: () => Promise<{
|
|
21
|
-
default: React.ComponentType;
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
24
|
-
export declare function getRouteObjects(routes: (NestedRoute | PageRoute)[], { globalApp, ssrMode, props, }: {
|
|
25
|
-
globalApp?: React.ComponentType<GlobalAppProps>;
|
|
26
|
-
ssrMode?: SSRMode;
|
|
27
|
-
props?: Record<string, unknown>;
|
|
28
|
-
}): RouteObject[];
|
|
29
|
-
export declare function createRouteObjectsFromConfig({ routesConfig, props, ssrMode, }: {
|
|
11
|
+
export declare function createTanstackRouteObjectsFromConfig({ routesConfig, }: {
|
|
30
12
|
routesConfig: RouterConfig['routesConfig'];
|
|
31
13
|
props?: Record<string, unknown>;
|
|
32
14
|
ssrMode?: SSRMode;
|
|
33
15
|
}): RouteObject[] | null;
|
|
34
|
-
export declare const urlJoin: (...parts: string[]) => string;
|
|
35
|
-
export declare function standardSlash(str: string): string;
|
|
36
16
|
export {};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modern.js",
|
|
19
19
|
"tanstack-router"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.5.0-ultramodern.
|
|
21
|
+
"version": "3.5.0-ultramodern.31",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -55,6 +55,20 @@
|
|
|
55
55
|
"module": "./dist/esm/runtime/router.mjs"
|
|
56
56
|
},
|
|
57
57
|
"default": "./dist/esm/runtime/router.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./runtime/rsc/client": {
|
|
60
|
+
"types": "./dist/types/runtime/rsc/client.d.ts",
|
|
61
|
+
"node": {
|
|
62
|
+
"module": "./dist/esm/runtime/rsc/client.mjs"
|
|
63
|
+
},
|
|
64
|
+
"default": "./dist/esm/runtime/rsc/client.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./runtime/rsc/server": {
|
|
67
|
+
"types": "./dist/types/runtime/rsc/server.d.ts",
|
|
68
|
+
"node": {
|
|
69
|
+
"module": "./dist/esm/runtime/rsc/server.mjs"
|
|
70
|
+
},
|
|
71
|
+
"default": "./dist/esm/runtime/rsc/server.mjs"
|
|
58
72
|
}
|
|
59
73
|
},
|
|
60
74
|
"typesVersions": {
|
|
@@ -70,6 +84,12 @@
|
|
|
70
84
|
],
|
|
71
85
|
"runtime/router": [
|
|
72
86
|
"./dist/types/runtime/router.d.ts"
|
|
87
|
+
],
|
|
88
|
+
"runtime/rsc/client": [
|
|
89
|
+
"./dist/types/runtime/rsc/client.d.ts"
|
|
90
|
+
],
|
|
91
|
+
"runtime/rsc/server": [
|
|
92
|
+
"./dist/types/runtime/rsc/server.d.ts"
|
|
73
93
|
]
|
|
74
94
|
}
|
|
75
95
|
},
|
|
@@ -77,13 +97,15 @@
|
|
|
77
97
|
"@swc/helpers": "^0.5.23",
|
|
78
98
|
"@tanstack/react-router": "1.170.16",
|
|
79
99
|
"@tanstack/router-core": "1.171.13",
|
|
80
|
-
"
|
|
81
|
-
"@modern-js/
|
|
82
|
-
"@modern-js/
|
|
83
|
-
"@modern-js/
|
|
100
|
+
"react-server-dom-rspack": "0.0.2",
|
|
101
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.31",
|
|
102
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.31",
|
|
103
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.31",
|
|
104
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.31"
|
|
84
105
|
},
|
|
85
106
|
"peerDependencies": {
|
|
86
|
-
"@modern-js/
|
|
107
|
+
"@modern-js/app-tools": "3.5.0-ultramodern.31",
|
|
108
|
+
"@modern-js/runtime": "3.5.0-ultramodern.31",
|
|
87
109
|
"react": "^19.2.7",
|
|
88
110
|
"react-dom": "^19.2.7"
|
|
89
111
|
},
|
|
@@ -98,8 +120,8 @@
|
|
|
98
120
|
"@typescript/native-preview": "7.0.0-dev.20260628.1",
|
|
99
121
|
"react": "^19.2.7",
|
|
100
122
|
"react-dom": "^19.2.7",
|
|
101
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.
|
|
102
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.
|
|
123
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.31",
|
|
124
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.31",
|
|
103
125
|
"@scripts/rstest-config": "2.66.0"
|
|
104
126
|
},
|
|
105
127
|
"sideEffects": [
|
package/rstest.config.mts
CHANGED
|
@@ -25,6 +25,7 @@ export default {
|
|
|
25
25
|
include: [
|
|
26
26
|
'tests/router/cli.test.ts',
|
|
27
27
|
'tests/router/fastDefaults.test.ts',
|
|
28
|
+
'tests/router/generateRouteArtifacts.test.ts',
|
|
28
29
|
'tests/router/hooks.test.ts',
|
|
29
30
|
'tests/router/loaderBridge.test.ts',
|
|
30
31
|
'tests/router/packageSurface.test.ts',
|
|
@@ -32,6 +33,7 @@ export default {
|
|
|
32
33
|
'tests/router/register.test.ts',
|
|
33
34
|
'tests/router/routeHooks.test.ts',
|
|
34
35
|
'tests/router/rsc.test.tsx',
|
|
36
|
+
'tests/router/ssrPreload.test.ts',
|
|
35
37
|
'tests/router/tanstackTypes.test.ts',
|
|
36
38
|
'tests/router/routeTree.test.ts',
|
|
37
39
|
],
|
|
@@ -44,6 +46,7 @@ export default {
|
|
|
44
46
|
'tests/router/dataMutation.test.tsx',
|
|
45
47
|
'tests/router/hydrationBoundary.test.tsx',
|
|
46
48
|
'tests/router/prefetchLink.test.tsx',
|
|
49
|
+
'tests/router/prefetchLinkPreload.test.tsx',
|
|
47
50
|
],
|
|
48
51
|
extends: commonConfig,
|
|
49
52
|
}),
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// @effect-diagnostics asyncFunction:off nodeBuiltinImport:off strictBooleanExpressions:off processEnv:off processEnvInEffect:off
|
|
2
|
+
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import type { AppToolsContext } from '@modern-js/app-tools';
|
|
5
|
+
import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
|
|
6
|
+
import { fs } from '@modern-js/utils';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
collectCanonicalRoutesForEntry,
|
|
10
|
+
generateTanstackRouterTypesSourceForEntry,
|
|
11
|
+
} from './tanstackTypes';
|
|
12
|
+
|
|
13
|
+
const DEFAULT_GENERATED_DIR_NAME = 'modern-tanstack';
|
|
14
|
+
|
|
15
|
+
async function writeFileIfChanged(filePath: string, content: string) {
|
|
16
|
+
try {
|
|
17
|
+
const previous = (await fs.pathExists(filePath))
|
|
18
|
+
? await fs.readFile(filePath, 'utf-8')
|
|
19
|
+
: null;
|
|
20
|
+
if (previous === content) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
// Fall through and rewrite the generated file.
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await fs.outputFile(filePath, content, 'utf-8');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createRegisterDtsContent(opts: {
|
|
31
|
+
entries: string[];
|
|
32
|
+
runtimeModule: string;
|
|
33
|
+
canonicalRoutes?: Record<string, string> | null;
|
|
34
|
+
i18nRuntimeModule?: string;
|
|
35
|
+
}) {
|
|
36
|
+
const importStatements = opts.entries
|
|
37
|
+
.map(
|
|
38
|
+
(entryName, index) =>
|
|
39
|
+
`import type { router as router${index} } from './${entryName}/router.gen';`,
|
|
40
|
+
)
|
|
41
|
+
.join('\n');
|
|
42
|
+
const routerUnionType = opts.entries
|
|
43
|
+
.map((_, index) => `typeof router${index}`)
|
|
44
|
+
.join(' | ');
|
|
45
|
+
|
|
46
|
+
const canonicalEntries = Object.entries(opts.canonicalRoutes ?? {});
|
|
47
|
+
const canonicalRoutesAugmentation =
|
|
48
|
+
canonicalEntries.length > 0
|
|
49
|
+
? `
|
|
50
|
+
declare module '${opts.i18nRuntimeModule || '@modern-js/plugin-i18n/runtime'}' {
|
|
51
|
+
interface UltramodernCanonicalRoutes {
|
|
52
|
+
${canonicalEntries
|
|
53
|
+
.map(([routePath, paramsType]) => ` '${routePath}': ${paramsType};`)
|
|
54
|
+
.join('\n')}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`
|
|
58
|
+
: '';
|
|
59
|
+
|
|
60
|
+
return `// This file is auto-generated by Modern.js. Do not edit manually.
|
|
61
|
+
|
|
62
|
+
${importStatements}
|
|
63
|
+
|
|
64
|
+
declare module '${opts.runtimeModule}' {
|
|
65
|
+
interface Register {
|
|
66
|
+
router: ${routerUnionType};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
${canonicalRoutesAugmentation}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function writeTanstackRegisterFile(opts: {
|
|
73
|
+
entries: string[];
|
|
74
|
+
generatedDirName?: string;
|
|
75
|
+
runtimeModule?: string;
|
|
76
|
+
srcDirectory: string;
|
|
77
|
+
canonicalRoutes?: Record<string, string> | null;
|
|
78
|
+
i18nRuntimeModule?: string;
|
|
79
|
+
}) {
|
|
80
|
+
const {
|
|
81
|
+
entries,
|
|
82
|
+
generatedDirName = DEFAULT_GENERATED_DIR_NAME,
|
|
83
|
+
runtimeModule = '@modern-js/plugin-tanstack/runtime',
|
|
84
|
+
srcDirectory,
|
|
85
|
+
canonicalRoutes,
|
|
86
|
+
i18nRuntimeModule,
|
|
87
|
+
} = opts;
|
|
88
|
+
|
|
89
|
+
if (entries.length === 0) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const registerDtsPath = path.join(
|
|
94
|
+
srcDirectory,
|
|
95
|
+
generatedDirName,
|
|
96
|
+
'register.gen.d.ts',
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
await writeFileIfChanged(
|
|
100
|
+
registerDtsPath,
|
|
101
|
+
createRegisterDtsContent({
|
|
102
|
+
entries,
|
|
103
|
+
runtimeModule,
|
|
104
|
+
canonicalRoutes,
|
|
105
|
+
i18nRuntimeModule,
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function writeTanstackRouterTypesForEntries(opts: {
|
|
111
|
+
appContext: AppToolsContext;
|
|
112
|
+
generatedDirName?: string;
|
|
113
|
+
routesByEntry: Record<string, (NestedRouteForCli | PageRoute)[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Whether `@modern-js/plugin-i18n` is actually installed in the app. The
|
|
116
|
+
* `register.gen.d.ts` augmentation of '@modern-js/plugin-i18n/runtime' is
|
|
117
|
+
* only emitted when this is true — otherwise apps with a hand-rolled
|
|
118
|
+
* `/:lang/` param would fail typechecking on an unresolvable module.
|
|
119
|
+
*/
|
|
120
|
+
i18nPluginInstalled?: boolean;
|
|
121
|
+
}) {
|
|
122
|
+
const {
|
|
123
|
+
appContext,
|
|
124
|
+
generatedDirName = DEFAULT_GENERATED_DIR_NAME,
|
|
125
|
+
routesByEntry,
|
|
126
|
+
i18nPluginInstalled = false,
|
|
127
|
+
} = opts;
|
|
128
|
+
|
|
129
|
+
const entryNames = Object.keys(routesByEntry);
|
|
130
|
+
|
|
131
|
+
await Promise.all(
|
|
132
|
+
entryNames.map(async entryName => {
|
|
133
|
+
const { routerGenTs } = await generateTanstackRouterTypesSourceForEntry({
|
|
134
|
+
appContext,
|
|
135
|
+
entryName,
|
|
136
|
+
generatedDirName,
|
|
137
|
+
routes: routesByEntry[entryName],
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await writeFileIfChanged(
|
|
141
|
+
path.join(
|
|
142
|
+
appContext.srcDirectory,
|
|
143
|
+
generatedDirName,
|
|
144
|
+
entryName,
|
|
145
|
+
'router.gen.ts',
|
|
146
|
+
),
|
|
147
|
+
routerGenTs,
|
|
148
|
+
);
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const mainEntryName = appContext.entrypoints?.find(
|
|
153
|
+
entrypoint => entrypoint.isMainEntry,
|
|
154
|
+
)?.entryName;
|
|
155
|
+
const registerEntries = entryNames.sort((a, b) => {
|
|
156
|
+
if (mainEntryName && a === mainEntryName) {
|
|
157
|
+
return -1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (mainEntryName && b === mainEntryName) {
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return a.localeCompare(b);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Merge the canonical (language-agnostic) route maps of every entry so the
|
|
168
|
+
// typed i18n Link covers all routes the app can navigate to. Only relevant
|
|
169
|
+
// when plugin-i18n is actually installed — without it the emitted module
|
|
170
|
+
// augmentation would reference an unresolvable module.
|
|
171
|
+
let canonicalRoutes: Record<string, string> | null = null;
|
|
172
|
+
if (i18nPluginInstalled) {
|
|
173
|
+
for (const entryName of registerEntries) {
|
|
174
|
+
const entryCanonicalRoutes = collectCanonicalRoutesForEntry(
|
|
175
|
+
routesByEntry[entryName],
|
|
176
|
+
{ localeParamHeuristic: true },
|
|
177
|
+
);
|
|
178
|
+
if (entryCanonicalRoutes) {
|
|
179
|
+
canonicalRoutes = {
|
|
180
|
+
...entryCanonicalRoutes,
|
|
181
|
+
...(canonicalRoutes ?? {}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
await writeTanstackRegisterFile({
|
|
188
|
+
entries: registerEntries,
|
|
189
|
+
generatedDirName,
|
|
190
|
+
srcDirectory: appContext.srcDirectory,
|
|
191
|
+
canonicalRoutes,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Headless regeneration of `router.gen.ts` / `register.gen.d.ts` for a generated
|
|
197
|
+
* app, without running a full dev/build. Drives the app-tools analyze `onPrepare`
|
|
198
|
+
* (which fires `generateEntryCode`) and returns before any bundling — the app's
|
|
199
|
+
* own registered plugin-tanstack writes the artifacts via its `generateEntryCode`
|
|
200
|
+
* subscriber. Reuses the exact hook dev/build use, so there is no scanning drift.
|
|
201
|
+
*/
|
|
202
|
+
export async function generateTanstackRouteArtifacts(opts: {
|
|
203
|
+
appDirectory: string;
|
|
204
|
+
version?: string;
|
|
205
|
+
}): Promise<void> {
|
|
206
|
+
const [{ createRunOptions }, { cli }, utils] = await Promise.all([
|
|
207
|
+
import('@modern-js/app-tools/cli/run'),
|
|
208
|
+
import('@modern-js/plugin/cli'),
|
|
209
|
+
import('@modern-js/utils'),
|
|
210
|
+
]);
|
|
211
|
+
// Load-bearing, not decoration: app-tools' analyze.onPrepare only fires
|
|
212
|
+
// generateEntryCode (the hook that writes the route artifacts) when
|
|
213
|
+
// checkIsBuildCommands() is true, and getCommand() resolves the command
|
|
214
|
+
// from MODERN_ARGV before process.argv — cli.init's `command` option does
|
|
215
|
+
// not feed that check.
|
|
216
|
+
process.env.MODERN_ARGV = 'node modern build';
|
|
217
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
218
|
+
|
|
219
|
+
// Resolve the app's Modern.js config file ourselves and pass it as an
|
|
220
|
+
// absolute base path. `createRunOptions` otherwise defaults its config lookup
|
|
221
|
+
// to `process.cwd()` (not `cwd`/appDirectory), so headless invocations that
|
|
222
|
+
// run from a different directory than the app — e.g. the create CLI spawning
|
|
223
|
+
// this from the workspace root — find no config, and `findExists` returns
|
|
224
|
+
// `false`. That `false` then flows into `cli.init` -> `getConfigFilePath` ->
|
|
225
|
+
// `path.isAbsolute(false)`, throwing the opaque
|
|
226
|
+
// `The "path" argument must be of type string. Received type boolean (false)`.
|
|
227
|
+
// Passing an absolute base is resolution-based: cwd no longer matters, and the
|
|
228
|
+
// downstream `getConfigFile` still appends the correct extension.
|
|
229
|
+
const { findExists, CONFIG_FILE_EXTENSIONS } = utils as {
|
|
230
|
+
findExists: (paths: string[]) => string | false;
|
|
231
|
+
CONFIG_FILE_EXTENSIONS: string[];
|
|
232
|
+
};
|
|
233
|
+
const configFileBase = path.resolve(opts.appDirectory, 'modern.config');
|
|
234
|
+
const resolvedConfigFile = findExists(
|
|
235
|
+
CONFIG_FILE_EXTENSIONS.map(extension => `${configFileBase}${extension}`),
|
|
236
|
+
);
|
|
237
|
+
if (!resolvedConfigFile) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`[plugin-tanstack] Unable to locate a Modern.js config file (modern.config.{${CONFIG_FILE_EXTENSIONS.map(
|
|
240
|
+
extension => extension.slice(1),
|
|
241
|
+
).join(',')}}) in ${opts.appDirectory}. ` +
|
|
242
|
+
'TanStack route generation requires the app config to resolve its plugins.',
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const runOptions = await createRunOptions({
|
|
247
|
+
cwd: opts.appDirectory,
|
|
248
|
+
configFile: configFileBase,
|
|
249
|
+
version:
|
|
250
|
+
opts.version || process.env.MODERN_JS_VERSION || '0.0.0-routes-generate',
|
|
251
|
+
internalPlugins: (utils as { INTERNAL_RUNTIME_PLUGINS: unknown })
|
|
252
|
+
.INTERNAL_RUNTIME_PLUGINS as never,
|
|
253
|
+
});
|
|
254
|
+
await cli.init({ ...runOptions, command: 'build' });
|
|
255
|
+
}
|