@tanstack/router-plugin 1.120.3 → 1.120.4-alpha.10
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/core/code-splitter/compilers.cjs +39 -21
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/compilers.d.cts +3 -0
- package/dist/cjs/core/code-splitter/framework-options.cjs +4 -8
- package/dist/cjs/core/code-splitter/framework-options.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/framework-options.d.cts +0 -2
- package/dist/cjs/core/config.d.cts +31 -40
- package/dist/cjs/core/route-autoimport-plugin.cjs +98 -0
- package/dist/cjs/core/route-autoimport-plugin.cjs.map +1 -0
- package/dist/cjs/core/route-autoimport-plugin.d.cts +6 -0
- package/dist/cjs/core/route-hmr-statement.cjs +33 -0
- package/dist/cjs/core/route-hmr-statement.cjs.map +1 -0
- package/dist/cjs/core/route-hmr-statement.d.cts +1 -0
- package/dist/cjs/core/router-code-splitter-plugin.cjs +11 -20
- package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-composed-plugin.cjs +19 -5
- package/dist/cjs/core/router-composed-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-generator-plugin.cjs +8 -2
- package/dist/cjs/core/router-generator-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-hmr-plugin.cjs +51 -0
- package/dist/cjs/core/router-hmr-plugin.cjs.map +1 -0
- package/dist/cjs/core/router-hmr-plugin.d.cts +8 -0
- package/dist/cjs/core/utils.cjs +12 -0
- package/dist/cjs/core/utils.cjs.map +1 -0
- package/dist/cjs/core/utils.d.cts +2 -0
- package/dist/cjs/esbuild.d.cts +21 -27
- package/dist/cjs/rspack.d.cts +21 -27
- package/dist/cjs/vite.cjs +2 -0
- package/dist/cjs/vite.cjs.map +1 -1
- package/dist/cjs/vite.d.cts +52 -26
- package/dist/cjs/webpack.d.cts +21 -27
- package/dist/esm/core/code-splitter/compilers.d.ts +3 -0
- package/dist/esm/core/code-splitter/compilers.js +39 -21
- package/dist/esm/core/code-splitter/compilers.js.map +1 -1
- package/dist/esm/core/code-splitter/framework-options.d.ts +0 -2
- package/dist/esm/core/code-splitter/framework-options.js +4 -8
- package/dist/esm/core/code-splitter/framework-options.js.map +1 -1
- package/dist/esm/core/config.d.ts +31 -40
- package/dist/esm/core/route-autoimport-plugin.d.ts +6 -0
- package/dist/esm/core/route-autoimport-plugin.js +81 -0
- package/dist/esm/core/route-autoimport-plugin.js.map +1 -0
- package/dist/esm/core/route-hmr-statement.d.ts +1 -0
- package/dist/esm/core/route-hmr-statement.js +16 -0
- package/dist/esm/core/route-hmr-statement.js.map +1 -0
- package/dist/esm/core/router-code-splitter-plugin.js +5 -14
- package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
- package/dist/esm/core/router-composed-plugin.js +19 -5
- package/dist/esm/core/router-composed-plugin.js.map +1 -1
- package/dist/esm/core/router-generator-plugin.js +8 -2
- package/dist/esm/core/router-generator-plugin.js.map +1 -1
- package/dist/esm/core/router-hmr-plugin.d.ts +8 -0
- package/dist/esm/core/router-hmr-plugin.js +51 -0
- package/dist/esm/core/router-hmr-plugin.js.map +1 -0
- package/dist/esm/core/utils.d.ts +2 -0
- package/dist/esm/core/utils.js +12 -0
- package/dist/esm/core/utils.js.map +1 -0
- package/dist/esm/esbuild.d.ts +21 -27
- package/dist/esm/rspack.d.ts +21 -27
- package/dist/esm/vite.d.ts +52 -26
- package/dist/esm/vite.js +3 -1
- package/dist/esm/vite.js.map +1 -1
- package/dist/esm/webpack.d.ts +21 -27
- package/package.json +6 -6
- package/src/core/code-splitter/compilers.ts +54 -27
- package/src/core/code-splitter/framework-options.ts +0 -6
- package/src/core/route-autoimport-plugin.ts +102 -0
- package/src/core/route-hmr-statement.ts +13 -0
- package/src/core/router-code-splitter-plugin.ts +3 -23
- package/src/core/router-composed-plugin.ts +20 -10
- package/src/core/router-generator-plugin.ts +12 -1
- package/src/core/router-hmr-plugin.ts +65 -0
- package/src/core/utils.ts +18 -0
- package/src/vite.ts +3 -0
package/dist/esm/vite.d.ts
CHANGED
|
@@ -12,31 +12,29 @@ declare const TanStackRouterGeneratorVite: (options?: Partial<{
|
|
|
12
12
|
target: "react" | "solid";
|
|
13
13
|
routeFileIgnorePrefix: string;
|
|
14
14
|
routesDirectory: string;
|
|
15
|
-
generatedRouteTree: string;
|
|
16
15
|
quoteStyle: "single" | "double";
|
|
17
16
|
semicolons: boolean;
|
|
17
|
+
disableLogging: boolean;
|
|
18
|
+
routeTreeFileHeader: string[];
|
|
19
|
+
indexToken: string;
|
|
20
|
+
routeToken: string;
|
|
21
|
+
generatedRouteTree: string;
|
|
18
22
|
disableTypes: boolean;
|
|
19
23
|
addExtensions: boolean;
|
|
20
|
-
disableLogging: boolean;
|
|
21
24
|
disableManifestGeneration: boolean;
|
|
22
25
|
enableRouteTreeFormatting: boolean;
|
|
23
|
-
apiBase: string;
|
|
24
|
-
routeTreeFileHeader: string[];
|
|
25
26
|
routeTreeFileFooter: string[];
|
|
26
|
-
indexToken: string;
|
|
27
|
-
routeToken: string;
|
|
28
27
|
enableRouteGeneration?: boolean | undefined;
|
|
29
28
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
30
29
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
31
30
|
routeFilePrefix?: string | undefined;
|
|
32
31
|
routeFileIgnorePattern?: string | undefined;
|
|
33
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
34
|
-
autoCodeSplitting?: boolean | undefined;
|
|
35
32
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
33
|
+
verboseFileRoutes?: boolean | undefined;
|
|
34
|
+
autoCodeSplitting?: boolean | undefined;
|
|
36
35
|
customScaffolding?: {
|
|
37
36
|
routeTemplate?: string | undefined;
|
|
38
37
|
lazyRouteTemplate?: string | undefined;
|
|
39
|
-
apiTemplate?: string | undefined;
|
|
40
38
|
} | undefined;
|
|
41
39
|
experimental?: {
|
|
42
40
|
enableCodeSplitting?: boolean | undefined;
|
|
@@ -55,31 +53,29 @@ declare const TanStackRouterCodeSplitterVite: (options?: Partial<{
|
|
|
55
53
|
target: "react" | "solid";
|
|
56
54
|
routeFileIgnorePrefix: string;
|
|
57
55
|
routesDirectory: string;
|
|
58
|
-
generatedRouteTree: string;
|
|
59
56
|
quoteStyle: "single" | "double";
|
|
60
57
|
semicolons: boolean;
|
|
58
|
+
disableLogging: boolean;
|
|
59
|
+
routeTreeFileHeader: string[];
|
|
60
|
+
indexToken: string;
|
|
61
|
+
routeToken: string;
|
|
62
|
+
generatedRouteTree: string;
|
|
61
63
|
disableTypes: boolean;
|
|
62
64
|
addExtensions: boolean;
|
|
63
|
-
disableLogging: boolean;
|
|
64
65
|
disableManifestGeneration: boolean;
|
|
65
66
|
enableRouteTreeFormatting: boolean;
|
|
66
|
-
apiBase: string;
|
|
67
|
-
routeTreeFileHeader: string[];
|
|
68
67
|
routeTreeFileFooter: string[];
|
|
69
|
-
indexToken: string;
|
|
70
|
-
routeToken: string;
|
|
71
68
|
enableRouteGeneration?: boolean | undefined;
|
|
72
69
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
73
70
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
74
71
|
routeFilePrefix?: string | undefined;
|
|
75
72
|
routeFileIgnorePattern?: string | undefined;
|
|
76
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
77
|
-
autoCodeSplitting?: boolean | undefined;
|
|
78
73
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
74
|
+
verboseFileRoutes?: boolean | undefined;
|
|
75
|
+
autoCodeSplitting?: boolean | undefined;
|
|
79
76
|
customScaffolding?: {
|
|
80
77
|
routeTemplate?: string | undefined;
|
|
81
78
|
lazyRouteTemplate?: string | undefined;
|
|
82
|
-
apiTemplate?: string | undefined;
|
|
83
79
|
} | undefined;
|
|
84
80
|
experimental?: {
|
|
85
81
|
enableCodeSplitting?: boolean | undefined;
|
|
@@ -98,36 +94,66 @@ declare const TanStackRouterVite: (options?: Partial<{
|
|
|
98
94
|
target: "react" | "solid";
|
|
99
95
|
routeFileIgnorePrefix: string;
|
|
100
96
|
routesDirectory: string;
|
|
101
|
-
generatedRouteTree: string;
|
|
102
97
|
quoteStyle: "single" | "double";
|
|
103
98
|
semicolons: boolean;
|
|
99
|
+
disableLogging: boolean;
|
|
100
|
+
routeTreeFileHeader: string[];
|
|
101
|
+
indexToken: string;
|
|
102
|
+
routeToken: string;
|
|
103
|
+
generatedRouteTree: string;
|
|
104
104
|
disableTypes: boolean;
|
|
105
105
|
addExtensions: boolean;
|
|
106
|
-
disableLogging: boolean;
|
|
107
106
|
disableManifestGeneration: boolean;
|
|
108
107
|
enableRouteTreeFormatting: boolean;
|
|
109
|
-
apiBase: string;
|
|
110
|
-
routeTreeFileHeader: string[];
|
|
111
108
|
routeTreeFileFooter: string[];
|
|
109
|
+
enableRouteGeneration?: boolean | undefined;
|
|
110
|
+
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
111
|
+
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
112
|
+
routeFilePrefix?: string | undefined;
|
|
113
|
+
routeFileIgnorePattern?: string | undefined;
|
|
114
|
+
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
115
|
+
verboseFileRoutes?: boolean | undefined;
|
|
116
|
+
autoCodeSplitting?: boolean | undefined;
|
|
117
|
+
customScaffolding?: {
|
|
118
|
+
routeTemplate?: string | undefined;
|
|
119
|
+
lazyRouteTemplate?: string | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
experimental?: {
|
|
122
|
+
enableCodeSplitting?: boolean | undefined;
|
|
123
|
+
} | undefined;
|
|
124
|
+
}> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
|
|
125
|
+
declare const tanstackRouter: (options?: Partial<{
|
|
126
|
+
target: "react" | "solid";
|
|
127
|
+
routeFileIgnorePrefix: string;
|
|
128
|
+
routesDirectory: string;
|
|
129
|
+
quoteStyle: "single" | "double";
|
|
130
|
+
semicolons: boolean;
|
|
131
|
+
disableLogging: boolean;
|
|
132
|
+
routeTreeFileHeader: string[];
|
|
112
133
|
indexToken: string;
|
|
113
134
|
routeToken: string;
|
|
135
|
+
generatedRouteTree: string;
|
|
136
|
+
disableTypes: boolean;
|
|
137
|
+
addExtensions: boolean;
|
|
138
|
+
disableManifestGeneration: boolean;
|
|
139
|
+
enableRouteTreeFormatting: boolean;
|
|
140
|
+
routeTreeFileFooter: string[];
|
|
114
141
|
enableRouteGeneration?: boolean | undefined;
|
|
115
142
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
116
143
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
117
144
|
routeFilePrefix?: string | undefined;
|
|
118
145
|
routeFileIgnorePattern?: string | undefined;
|
|
119
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
120
|
-
autoCodeSplitting?: boolean | undefined;
|
|
121
146
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
147
|
+
verboseFileRoutes?: boolean | undefined;
|
|
148
|
+
autoCodeSplitting?: boolean | undefined;
|
|
122
149
|
customScaffolding?: {
|
|
123
150
|
routeTemplate?: string | undefined;
|
|
124
151
|
lazyRouteTemplate?: string | undefined;
|
|
125
|
-
apiTemplate?: string | undefined;
|
|
126
152
|
} | undefined;
|
|
127
153
|
experimental?: {
|
|
128
154
|
enableCodeSplitting?: boolean | undefined;
|
|
129
155
|
} | undefined;
|
|
130
156
|
}> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
|
|
131
157
|
export default TanStackRouterVite;
|
|
132
|
-
export { configSchema, TanStackRouterGeneratorVite, TanStackRouterCodeSplitterVite, TanStackRouterVite, };
|
|
158
|
+
export { configSchema, TanStackRouterGeneratorVite, TanStackRouterCodeSplitterVite, TanStackRouterVite, tanstackRouter, };
|
|
133
159
|
export type { Config };
|
package/dist/esm/vite.js
CHANGED
|
@@ -10,11 +10,13 @@ const TanStackRouterCodeSplitterVite = createVitePlugin(
|
|
|
10
10
|
unpluginRouterCodeSplitterFactory
|
|
11
11
|
);
|
|
12
12
|
const TanStackRouterVite = createVitePlugin(unpluginRouterComposedFactory);
|
|
13
|
+
const tanstackRouter = TanStackRouterVite;
|
|
13
14
|
export {
|
|
14
15
|
TanStackRouterCodeSplitterVite,
|
|
15
16
|
TanStackRouterGeneratorVite,
|
|
16
17
|
TanStackRouterVite,
|
|
17
18
|
configSchema,
|
|
18
|
-
TanStackRouterVite as default
|
|
19
|
+
TanStackRouterVite as default,
|
|
20
|
+
tanstackRouter
|
|
19
21
|
};
|
|
20
22
|
//# sourceMappingURL=vite.js.map
|
package/dist/esm/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sources":["../../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\n\nimport type { Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterGeneratorVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterGeneratorVite = createVitePlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterCodeSplitterVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterCodeSplitterVite = createVitePlugin(\n unpluginRouterCodeSplitterFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterVite = createVitePlugin(unpluginRouterComposedFactory)\n\nexport default TanStackRouterVite\nexport {\n configSchema,\n TanStackRouterGeneratorVite,\n TanStackRouterCodeSplitterVite,\n TanStackRouterVite,\n}\nexport type { Config }\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,8BAA8B;AAAA,EAClC;AACF;AAWA,MAAM,iCAAiC;AAAA,EACrC;AACF;AAWM,MAAA,qBAAqB,iBAAiB,6BAA6B;"}
|
|
1
|
+
{"version":3,"file":"vite.js","sources":["../../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\n\nimport type { Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterGeneratorVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterGeneratorVite = createVitePlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterCodeSplitterVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterCodeSplitterVite = createVitePlugin(\n unpluginRouterCodeSplitterFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [TanStackRouterVite()],\n * // ...\n * })\n * ```\n */\nconst TanStackRouterVite = createVitePlugin(unpluginRouterComposedFactory)\nconst tanstackRouter = TanStackRouterVite\n\nexport default TanStackRouterVite\nexport {\n configSchema,\n TanStackRouterGeneratorVite,\n TanStackRouterCodeSplitterVite,\n TanStackRouterVite,\n tanstackRouter,\n}\n\nexport type { Config }\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,8BAA8B;AAAA,EAClC;AACF;AAWA,MAAM,iCAAiC;AAAA,EACrC;AACF;AAWM,MAAA,qBAAqB,iBAAiB,6BAA6B;AACzE,MAAM,iBAAiB;"}
|
package/dist/esm/webpack.d.ts
CHANGED
|
@@ -12,31 +12,29 @@ declare const TanStackRouterGeneratorWebpack: (options?: Partial<{
|
|
|
12
12
|
target: "react" | "solid";
|
|
13
13
|
routeFileIgnorePrefix: string;
|
|
14
14
|
routesDirectory: string;
|
|
15
|
-
generatedRouteTree: string;
|
|
16
15
|
quoteStyle: "single" | "double";
|
|
17
16
|
semicolons: boolean;
|
|
17
|
+
disableLogging: boolean;
|
|
18
|
+
routeTreeFileHeader: string[];
|
|
19
|
+
indexToken: string;
|
|
20
|
+
routeToken: string;
|
|
21
|
+
generatedRouteTree: string;
|
|
18
22
|
disableTypes: boolean;
|
|
19
23
|
addExtensions: boolean;
|
|
20
|
-
disableLogging: boolean;
|
|
21
24
|
disableManifestGeneration: boolean;
|
|
22
25
|
enableRouteTreeFormatting: boolean;
|
|
23
|
-
apiBase: string;
|
|
24
|
-
routeTreeFileHeader: string[];
|
|
25
26
|
routeTreeFileFooter: string[];
|
|
26
|
-
indexToken: string;
|
|
27
|
-
routeToken: string;
|
|
28
27
|
enableRouteGeneration?: boolean | undefined;
|
|
29
28
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
30
29
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
31
30
|
routeFilePrefix?: string | undefined;
|
|
32
31
|
routeFileIgnorePattern?: string | undefined;
|
|
33
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
34
|
-
autoCodeSplitting?: boolean | undefined;
|
|
35
32
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
33
|
+
verboseFileRoutes?: boolean | undefined;
|
|
34
|
+
autoCodeSplitting?: boolean | undefined;
|
|
36
35
|
customScaffolding?: {
|
|
37
36
|
routeTemplate?: string | undefined;
|
|
38
37
|
lazyRouteTemplate?: string | undefined;
|
|
39
|
-
apiTemplate?: string | undefined;
|
|
40
38
|
} | undefined;
|
|
41
39
|
experimental?: {
|
|
42
40
|
enableCodeSplitting?: boolean | undefined;
|
|
@@ -55,31 +53,29 @@ declare const TanStackRouterCodeSplitterWebpack: (options?: Partial<{
|
|
|
55
53
|
target: "react" | "solid";
|
|
56
54
|
routeFileIgnorePrefix: string;
|
|
57
55
|
routesDirectory: string;
|
|
58
|
-
generatedRouteTree: string;
|
|
59
56
|
quoteStyle: "single" | "double";
|
|
60
57
|
semicolons: boolean;
|
|
58
|
+
disableLogging: boolean;
|
|
59
|
+
routeTreeFileHeader: string[];
|
|
60
|
+
indexToken: string;
|
|
61
|
+
routeToken: string;
|
|
62
|
+
generatedRouteTree: string;
|
|
61
63
|
disableTypes: boolean;
|
|
62
64
|
addExtensions: boolean;
|
|
63
|
-
disableLogging: boolean;
|
|
64
65
|
disableManifestGeneration: boolean;
|
|
65
66
|
enableRouteTreeFormatting: boolean;
|
|
66
|
-
apiBase: string;
|
|
67
|
-
routeTreeFileHeader: string[];
|
|
68
67
|
routeTreeFileFooter: string[];
|
|
69
|
-
indexToken: string;
|
|
70
|
-
routeToken: string;
|
|
71
68
|
enableRouteGeneration?: boolean | undefined;
|
|
72
69
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
73
70
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
74
71
|
routeFilePrefix?: string | undefined;
|
|
75
72
|
routeFileIgnorePattern?: string | undefined;
|
|
76
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
77
|
-
autoCodeSplitting?: boolean | undefined;
|
|
78
73
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
74
|
+
verboseFileRoutes?: boolean | undefined;
|
|
75
|
+
autoCodeSplitting?: boolean | undefined;
|
|
79
76
|
customScaffolding?: {
|
|
80
77
|
routeTemplate?: string | undefined;
|
|
81
78
|
lazyRouteTemplate?: string | undefined;
|
|
82
|
-
apiTemplate?: string | undefined;
|
|
83
79
|
} | undefined;
|
|
84
80
|
experimental?: {
|
|
85
81
|
enableCodeSplitting?: boolean | undefined;
|
|
@@ -98,31 +94,29 @@ declare const TanStackRouterWebpack: (options?: Partial<{
|
|
|
98
94
|
target: "react" | "solid";
|
|
99
95
|
routeFileIgnorePrefix: string;
|
|
100
96
|
routesDirectory: string;
|
|
101
|
-
generatedRouteTree: string;
|
|
102
97
|
quoteStyle: "single" | "double";
|
|
103
98
|
semicolons: boolean;
|
|
99
|
+
disableLogging: boolean;
|
|
100
|
+
routeTreeFileHeader: string[];
|
|
101
|
+
indexToken: string;
|
|
102
|
+
routeToken: string;
|
|
103
|
+
generatedRouteTree: string;
|
|
104
104
|
disableTypes: boolean;
|
|
105
105
|
addExtensions: boolean;
|
|
106
|
-
disableLogging: boolean;
|
|
107
106
|
disableManifestGeneration: boolean;
|
|
108
107
|
enableRouteTreeFormatting: boolean;
|
|
109
|
-
apiBase: string;
|
|
110
|
-
routeTreeFileHeader: string[];
|
|
111
108
|
routeTreeFileFooter: string[];
|
|
112
|
-
indexToken: string;
|
|
113
|
-
routeToken: string;
|
|
114
109
|
enableRouteGeneration?: boolean | undefined;
|
|
115
110
|
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
116
111
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
117
112
|
routeFilePrefix?: string | undefined;
|
|
118
113
|
routeFileIgnorePattern?: string | undefined;
|
|
119
|
-
__enableAPIRoutesGeneration?: boolean | undefined;
|
|
120
|
-
autoCodeSplitting?: boolean | undefined;
|
|
121
114
|
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
115
|
+
verboseFileRoutes?: boolean | undefined;
|
|
116
|
+
autoCodeSplitting?: boolean | undefined;
|
|
122
117
|
customScaffolding?: {
|
|
123
118
|
routeTemplate?: string | undefined;
|
|
124
119
|
lazyRouteTemplate?: string | undefined;
|
|
125
|
-
apiTemplate?: string | undefined;
|
|
126
120
|
} | undefined;
|
|
127
121
|
experimental?: {
|
|
128
122
|
enableCodeSplitting?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-plugin",
|
|
3
|
-
"version": "1.120.
|
|
3
|
+
"version": "1.120.4-alpha.10",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -100,17 +100,17 @@
|
|
|
100
100
|
"chokidar": "^3.6.0",
|
|
101
101
|
"unplugin": "^2.1.2",
|
|
102
102
|
"zod": "^3.24.2",
|
|
103
|
-
"@tanstack/router-core": "^1.120.
|
|
104
|
-
"@tanstack/
|
|
105
|
-
"@tanstack/
|
|
106
|
-
"@tanstack/router-
|
|
103
|
+
"@tanstack/router-core": "^1.120.4-alpha.10",
|
|
104
|
+
"@tanstack/router-generator": "^1.120.4-alpha.10",
|
|
105
|
+
"@tanstack/virtual-file-routes": "^1.120.4-alpha.1",
|
|
106
|
+
"@tanstack/router-utils": "^1.120.4-alpha.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"@rsbuild/core": ">=1.0.2",
|
|
110
110
|
"vite": ">=5.0.0 || >=6.0.0",
|
|
111
111
|
"vite-plugin-solid": "^2.11.2",
|
|
112
112
|
"webpack": ">=5.92.0",
|
|
113
|
-
"@tanstack/react-router": "^1.120.
|
|
113
|
+
"@tanstack/react-router": "^1.120.4-alpha.10"
|
|
114
114
|
},
|
|
115
115
|
"peerDependenciesMeta": {
|
|
116
116
|
"@rsbuild/core": {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from 'babel-dead-code-elimination'
|
|
8
8
|
import { generateFromAst, parseAst } from '@tanstack/router-utils'
|
|
9
9
|
import { tsrSplit } from '../constants'
|
|
10
|
+
import { routeHmrStatement } from '../route-hmr-statement'
|
|
10
11
|
import { createIdentifier } from './path-ids'
|
|
11
12
|
import { getFrameworkOptions } from './framework-options'
|
|
12
13
|
import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils'
|
|
@@ -117,6 +118,8 @@ export function compileCodeSplitReferenceRoute(
|
|
|
117
118
|
runtimeEnv: 'dev' | 'prod'
|
|
118
119
|
codeSplitGroupings: CodeSplitGroupings
|
|
119
120
|
targetFramework: Config['target']
|
|
121
|
+
filename: string
|
|
122
|
+
id: string
|
|
120
123
|
},
|
|
121
124
|
): GeneratorResult {
|
|
122
125
|
const ast = parseAst(opts)
|
|
@@ -166,18 +169,13 @@ export function compileCodeSplitReferenceRoute(
|
|
|
166
169
|
return
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
const options = resolveIdentifier(
|
|
171
|
-
path,
|
|
172
|
-
path.parentPath.node.arguments[0],
|
|
173
|
-
)
|
|
174
|
-
|
|
172
|
+
function babelHandleReference(routeOptions: t.Node | undefined) {
|
|
175
173
|
const hasImportedOrDefinedIdentifier = (name: string) => {
|
|
176
174
|
return programPath.scope.hasBinding(name)
|
|
177
175
|
}
|
|
178
176
|
|
|
179
|
-
if (t.isObjectExpression(
|
|
180
|
-
|
|
177
|
+
if (t.isObjectExpression(routeOptions)) {
|
|
178
|
+
routeOptions.properties.forEach((prop) => {
|
|
181
179
|
if (t.isObjectProperty(prop)) {
|
|
182
180
|
if (t.isIdentifier(prop.key)) {
|
|
183
181
|
// If the user has not specified a split grouping for this key
|
|
@@ -288,18 +286,9 @@ export function compileCodeSplitReferenceRoute(
|
|
|
288
286
|
)()
|
|
289
287
|
}
|
|
290
288
|
|
|
291
|
-
//
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
!hasImportedOrDefinedIdentifier(
|
|
295
|
-
frameworkOptions.idents.dummyHMRComponent,
|
|
296
|
-
)
|
|
297
|
-
) {
|
|
298
|
-
programPath.pushContainer('body', [
|
|
299
|
-
template.statement(
|
|
300
|
-
frameworkOptions.dummyHMRComponent,
|
|
301
|
-
)(),
|
|
302
|
-
])
|
|
289
|
+
// add HMR handling
|
|
290
|
+
if (opts.runtimeEnv !== 'prod') {
|
|
291
|
+
programPath.pushContainer('body', routeHmrStatement)
|
|
303
292
|
}
|
|
304
293
|
}
|
|
305
294
|
|
|
@@ -369,6 +358,27 @@ export function compileCodeSplitReferenceRoute(
|
|
|
369
358
|
})
|
|
370
359
|
}
|
|
371
360
|
}
|
|
361
|
+
|
|
362
|
+
if (t.isCallExpression(path.parentPath.node)) {
|
|
363
|
+
// createFileRoute('/')({ ... })
|
|
364
|
+
const options = resolveIdentifier(
|
|
365
|
+
path,
|
|
366
|
+
path.parentPath.node.arguments[0],
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
babelHandleReference(options)
|
|
370
|
+
} else if (t.isVariableDeclarator(path.parentPath.node)) {
|
|
371
|
+
// createFileRoute({ ... })
|
|
372
|
+
const caller = resolveIdentifier(
|
|
373
|
+
path,
|
|
374
|
+
path.parentPath.node.init,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
if (t.isCallExpression(caller)) {
|
|
378
|
+
const options = resolveIdentifier(path, caller.arguments[0])
|
|
379
|
+
babelHandleReference(options)
|
|
380
|
+
}
|
|
381
|
+
}
|
|
372
382
|
},
|
|
373
383
|
},
|
|
374
384
|
state,
|
|
@@ -406,6 +416,7 @@ export function compileCodeSplitReferenceRoute(
|
|
|
406
416
|
export function compileCodeSplitVirtualRoute(
|
|
407
417
|
opts: ParseAstOptions & {
|
|
408
418
|
splitTargets: Array<SplitRouteIdentNodes>
|
|
419
|
+
filename: string
|
|
409
420
|
},
|
|
410
421
|
): GeneratorResult {
|
|
411
422
|
const ast = parseAst(opts)
|
|
@@ -448,12 +459,7 @@ export function compileCodeSplitVirtualRoute(
|
|
|
448
459
|
return
|
|
449
460
|
}
|
|
450
461
|
|
|
451
|
-
|
|
452
|
-
const options = resolveIdentifier(
|
|
453
|
-
path,
|
|
454
|
-
path.parentPath.node.arguments[0],
|
|
455
|
-
)
|
|
456
|
-
|
|
462
|
+
function babelHandleVirtual(options: t.Node | undefined) {
|
|
457
463
|
if (t.isObjectExpression(options)) {
|
|
458
464
|
options.properties.forEach((prop) => {
|
|
459
465
|
if (t.isObjectProperty(prop)) {
|
|
@@ -497,6 +503,27 @@ export function compileCodeSplitVirtualRoute(
|
|
|
497
503
|
options.properties = []
|
|
498
504
|
}
|
|
499
505
|
}
|
|
506
|
+
|
|
507
|
+
if (t.isCallExpression(path.parentPath.node)) {
|
|
508
|
+
// createFileRoute('/')({ ... })
|
|
509
|
+
const options = resolveIdentifier(
|
|
510
|
+
path,
|
|
511
|
+
path.parentPath.node.arguments[0],
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
babelHandleVirtual(options)
|
|
515
|
+
} else if (t.isVariableDeclarator(path.parentPath.node)) {
|
|
516
|
+
// createFileRoute({ ... })
|
|
517
|
+
const caller = resolveIdentifier(
|
|
518
|
+
path,
|
|
519
|
+
path.parentPath.node.init,
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
if (t.isCallExpression(caller)) {
|
|
523
|
+
const options = resolveIdentifier(path, caller.arguments[0])
|
|
524
|
+
babelHandleVirtual(options)
|
|
525
|
+
}
|
|
526
|
+
}
|
|
500
527
|
},
|
|
501
528
|
},
|
|
502
529
|
state,
|
|
@@ -841,7 +868,7 @@ function getImportSpecifierAndPathFromLocalName(
|
|
|
841
868
|
}
|
|
842
869
|
|
|
843
870
|
// Reusable function to get literal value or resolve variable to literal
|
|
844
|
-
function resolveIdentifier(path: any, node: any) {
|
|
871
|
+
function resolveIdentifier(path: any, node: any): t.Node | undefined {
|
|
845
872
|
if (t.isIdentifier(node)) {
|
|
846
873
|
const binding = path.scope.getBinding(node.name)
|
|
847
874
|
if (
|
|
@@ -4,9 +4,7 @@ type FrameworkOptions = {
|
|
|
4
4
|
createFileRoute: string
|
|
5
5
|
lazyFn: string
|
|
6
6
|
lazyRouteComponent: string
|
|
7
|
-
dummyHMRComponent: string
|
|
8
7
|
}
|
|
9
|
-
dummyHMRComponent: string
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export function getFrameworkOptions(framework: string): FrameworkOptions {
|
|
@@ -20,9 +18,7 @@ export function getFrameworkOptions(framework: string): FrameworkOptions {
|
|
|
20
18
|
createFileRoute: 'createFileRoute',
|
|
21
19
|
lazyFn: 'lazyFn',
|
|
22
20
|
lazyRouteComponent: 'lazyRouteComponent',
|
|
23
|
-
dummyHMRComponent: 'TSRDummyComponent',
|
|
24
21
|
},
|
|
25
|
-
dummyHMRComponent: `export function TSRDummyComponent() { return null }`,
|
|
26
22
|
}
|
|
27
23
|
break
|
|
28
24
|
case 'solid':
|
|
@@ -32,9 +28,7 @@ export function getFrameworkOptions(framework: string): FrameworkOptions {
|
|
|
32
28
|
createFileRoute: 'createFileRoute',
|
|
33
29
|
lazyFn: 'lazyFn',
|
|
34
30
|
lazyRouteComponent: 'lazyRouteComponent',
|
|
35
|
-
dummyHMRComponent: 'TSRDummyComponent',
|
|
36
31
|
},
|
|
37
|
-
dummyHMRComponent: `export function TSRDummyComponent() { return null }`,
|
|
38
32
|
}
|
|
39
33
|
break
|
|
40
34
|
default:
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'
|
|
2
|
+
import babel from '@babel/core'
|
|
3
|
+
import * as template from '@babel/template'
|
|
4
|
+
import { getConfig } from './config'
|
|
5
|
+
import { debug, fileIsInRoutesDirectory } from './utils'
|
|
6
|
+
import type { Config } from './config'
|
|
7
|
+
import type { UnpluginFactory } from 'unplugin'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This plugin adds imports for createFileRoute and createLazyFileRoute to the file route.
|
|
11
|
+
*/
|
|
12
|
+
export const unpluginRouteAutoimportFactory: UnpluginFactory<
|
|
13
|
+
Partial<Config> | undefined
|
|
14
|
+
> = (options = {}) => {
|
|
15
|
+
let ROOT: string = process.cwd()
|
|
16
|
+
let userConfig = options as Config
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: 'router-autoimport-plugin',
|
|
20
|
+
enforce: 'pre',
|
|
21
|
+
|
|
22
|
+
transform(code, id) {
|
|
23
|
+
let routeType: 'createFileRoute' | 'createLazyFileRoute'
|
|
24
|
+
if (code.includes('export const Route = createFileRoute(')) {
|
|
25
|
+
routeType = 'createFileRoute'
|
|
26
|
+
} else if (code.includes('export const Route = createLazyFileRoute(')) {
|
|
27
|
+
routeType = 'createLazyFileRoute'
|
|
28
|
+
} else {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const routerImportPath = `@tanstack/${userConfig.target}-router`
|
|
33
|
+
|
|
34
|
+
const ast = parseAst({ code })
|
|
35
|
+
|
|
36
|
+
let isCreateRouteFunctionImported = false as boolean
|
|
37
|
+
|
|
38
|
+
babel.traverse(ast, {
|
|
39
|
+
Program: {
|
|
40
|
+
enter(programPath) {
|
|
41
|
+
programPath.traverse({
|
|
42
|
+
ImportDeclaration(path) {
|
|
43
|
+
const importedSpecifiers = path.node.specifiers.map(
|
|
44
|
+
(specifier) => specifier.local.name,
|
|
45
|
+
)
|
|
46
|
+
if (
|
|
47
|
+
importedSpecifiers.includes(routeType) &&
|
|
48
|
+
path.node.source.value === routerImportPath
|
|
49
|
+
) {
|
|
50
|
+
isCreateRouteFunctionImported = true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
if (!isCreateRouteFunctionImported) {
|
|
59
|
+
if (debug) console.info('Adding autoimports to route ', id)
|
|
60
|
+
|
|
61
|
+
const autoImportStatement = template.statement(
|
|
62
|
+
`import { ${routeType} } from '${routerImportPath}'`,
|
|
63
|
+
)()
|
|
64
|
+
ast.program.body.unshift(autoImportStatement)
|
|
65
|
+
|
|
66
|
+
const result = generateFromAst(ast, {
|
|
67
|
+
sourceMaps: true,
|
|
68
|
+
filename: id,
|
|
69
|
+
sourceFileName: id,
|
|
70
|
+
})
|
|
71
|
+
if (debug) {
|
|
72
|
+
logDiff(code, result.code)
|
|
73
|
+
console.log('Output:\n', result.code + '\n\n')
|
|
74
|
+
}
|
|
75
|
+
return result
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return null
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
transformInclude(id) {
|
|
82
|
+
return fileIsInRoutesDirectory(id, userConfig.routesDirectory)
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
vite: {
|
|
86
|
+
configResolved(config) {
|
|
87
|
+
ROOT = config.root
|
|
88
|
+
userConfig = getConfig(options, ROOT)
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
rspack() {
|
|
93
|
+
ROOT = process.cwd()
|
|
94
|
+
userConfig = getConfig(options, ROOT)
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
webpack() {
|
|
98
|
+
ROOT = process.cwd()
|
|
99
|
+
userConfig = getConfig(options, ROOT)
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as template from '@babel/template'
|
|
2
|
+
|
|
3
|
+
export const routeHmrStatement = template.statement(
|
|
4
|
+
`
|
|
5
|
+
if (import.meta.hot) {
|
|
6
|
+
import.meta.hot.accept((newModule) => {
|
|
7
|
+
if (newModule.Route && typeof newModule.Route.clone === 'function') {
|
|
8
|
+
newModule.Route.clone(Route)
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
)()
|