@tanstack/router-plugin 1.168.6 → 1.168.8
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 +32 -233
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/compilers.d.cts +2 -57
- package/dist/cjs/core/code-splitter/plugins.d.cts +1 -0
- package/dist/cjs/core/config.cjs +1 -1
- package/dist/cjs/core/config.cjs.map +1 -1
- package/dist/cjs/core/config.d.cts +44 -163
- package/dist/cjs/core/router-code-splitter-plugin.cjs +5 -6
- package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
- package/dist/cjs/esbuild.d.cts +26 -26
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.d.cts +2 -0
- package/dist/cjs/vite.d.cts +26 -26
- package/dist/esm/core/code-splitter/compilers.d.ts +2 -57
- package/dist/esm/core/code-splitter/compilers.js +15 -216
- package/dist/esm/core/code-splitter/compilers.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins.d.ts +1 -0
- package/dist/esm/core/config.d.ts +44 -163
- package/dist/esm/core/config.js +1 -1
- package/dist/esm/core/config.js.map +1 -1
- package/dist/esm/core/router-code-splitter-plugin.js +5 -6
- package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
- package/dist/esm/esbuild.d.ts +26 -26
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/vite.d.ts +26 -26
- package/package.json +7 -7
- package/src/core/code-splitter/compilers.ts +51 -411
- package/src/core/code-splitter/plugins.ts +3 -0
- package/src/core/config.ts +12 -1
- package/src/core/router-code-splitter-plugin.ts +11 -9
- package/src/index.ts +5 -0
- package/dist/cjs/core/code-splitter/path-ids.cjs +0 -32
- package/dist/cjs/core/code-splitter/path-ids.cjs.map +0 -1
- package/dist/cjs/core/code-splitter/path-ids.d.cts +0 -2
- package/dist/esm/core/code-splitter/path-ids.d.ts +0 -2
- package/dist/esm/core/code-splitter/path-ids.js +0 -31
- package/dist/esm/core/code-splitter/path-ids.js.map +0 -1
- package/src/core/code-splitter/path-ids.ts +0 -39
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { CreateFileRoute, RegisteredRouter, RouteIds } from '@tanstack/router-core';
|
|
3
3
|
import { CodeSplitGroupings } from './constants.cjs';
|
|
4
|
-
export declare const splitGroupingsSchema: z.
|
|
4
|
+
export declare const splitGroupingsSchema: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"loader">, z.ZodLiteral<"component">, z.ZodLiteral<"pendingComponent">, z.ZodLiteral<"errorComponent">, z.ZodLiteral<"notFoundComponent">]>>>;
|
|
5
5
|
export type CodeSplittingOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* Use this function to programmatically control the code splitting behavior
|
|
@@ -42,99 +42,73 @@ export type HmrOptions = {
|
|
|
42
42
|
type FileRouteKeys = keyof (Parameters<CreateFileRoute<any, any, any, any, any>>[0] & {});
|
|
43
43
|
export type DeletableNodes = FileRouteKeys | (string & {});
|
|
44
44
|
export declare const configSchema: z.ZodObject<{
|
|
45
|
-
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
46
|
-
|
|
45
|
+
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
vue: "vue";
|
|
47
|
+
react: "react";
|
|
48
|
+
solid: "solid";
|
|
49
|
+
}>>>;
|
|
50
|
+
virtualRouteConfig: z.ZodOptional<z.ZodUnion<[z.ZodType<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown, z.core.$ZodTypeInternals<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown>>, z.ZodString]>>;
|
|
47
51
|
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
48
52
|
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
49
53
|
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
50
54
|
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
51
|
-
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
55
|
+
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
single: "single";
|
|
57
|
+
double: "double";
|
|
58
|
+
}>>>;
|
|
52
59
|
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
53
60
|
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
54
|
-
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString
|
|
55
|
-
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.
|
|
61
|
+
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
62
|
+
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
56
63
|
regex: z.ZodString;
|
|
57
64
|
flags: z.ZodOptional<z.ZodString>;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
flags?: string | undefined;
|
|
61
|
-
}, {
|
|
62
|
-
regex: string;
|
|
63
|
-
flags?: string | undefined;
|
|
64
|
-
}>]>>>;
|
|
65
|
-
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodObject<{
|
|
65
|
+
}, z.core.$strip>]>>>;
|
|
66
|
+
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
66
67
|
regex: z.ZodString;
|
|
67
68
|
flags: z.ZodOptional<z.ZodString>;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
}, z.core.$strip>]>>>;
|
|
70
|
+
pathParamsAllowedCharacters: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
71
|
+
":": ":";
|
|
72
|
+
$: "$";
|
|
73
|
+
";": ";";
|
|
74
|
+
"@": "@";
|
|
75
|
+
"&": "&";
|
|
76
|
+
"=": "=";
|
|
77
|
+
"+": "+";
|
|
78
|
+
",": ",";
|
|
79
|
+
}>>>;
|
|
77
80
|
generatedRouteTree: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
78
81
|
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
79
|
-
addExtensions: z.
|
|
82
|
+
addExtensions: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>, z.ZodTransform<string | boolean, string | boolean>>;
|
|
80
83
|
enableRouteTreeFormatting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
81
|
-
routeTreeFileFooter: z.ZodOptional<z.ZodUnion<[z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString
|
|
84
|
+
routeTreeFileFooter: z.ZodOptional<z.ZodUnion<readonly [z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>, z.ZodCustom<() => Array<string>, () => Array<string>>]>>;
|
|
82
85
|
autoCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
83
86
|
customScaffolding: z.ZodOptional<z.ZodObject<{
|
|
84
87
|
routeTemplate: z.ZodOptional<z.ZodString>;
|
|
85
88
|
lazyRouteTemplate: z.ZodOptional<z.ZodString>;
|
|
86
|
-
},
|
|
87
|
-
routeTemplate?: string | undefined;
|
|
88
|
-
lazyRouteTemplate?: string | undefined;
|
|
89
|
-
}, {
|
|
90
|
-
routeTemplate?: string | undefined;
|
|
91
|
-
lazyRouteTemplate?: string | undefined;
|
|
92
|
-
}>>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
93
90
|
experimental: z.ZodOptional<z.ZodObject<{
|
|
94
91
|
enableCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
}, {
|
|
98
|
-
enableCodeSplitting?: boolean | undefined;
|
|
99
|
-
}>>;
|
|
100
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodType<import('@tanstack/router-generator').GeneratorPlugin, z.ZodTypeDef, import('@tanstack/router-generator').GeneratorPlugin>, "many">>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodCustom<import('@tanstack/router-generator').GeneratorPlugin, import('@tanstack/router-generator').GeneratorPlugin>>>;
|
|
101
94
|
tmpDir: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
102
95
|
importRoutesUsingAbsolutePaths: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
103
|
-
} & {
|
|
104
96
|
enableRouteGeneration: z.ZodOptional<z.ZodBoolean>;
|
|
105
|
-
codeSplittingOptions: z.ZodOptional<z.
|
|
97
|
+
codeSplittingOptions: z.ZodOptional<z.ZodCustom<CodeSplittingOptions, CodeSplittingOptions>>;
|
|
106
98
|
plugin: z.ZodOptional<z.ZodObject<{
|
|
107
99
|
hmr: z.ZodOptional<z.ZodObject<{
|
|
108
|
-
style: z.ZodOptional<z.ZodEnum<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}>>;
|
|
100
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
vite: "vite";
|
|
102
|
+
webpack: "webpack";
|
|
103
|
+
}>>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
114
105
|
vite: z.ZodOptional<z.ZodObject<{
|
|
115
106
|
environmentName: z.ZodOptional<z.ZodString>;
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, "strip", z.ZodTypeAny, {
|
|
122
|
-
vite?: {
|
|
123
|
-
environmentName?: string | undefined;
|
|
124
|
-
} | undefined;
|
|
125
|
-
hmr?: {
|
|
126
|
-
style?: "vite" | "webpack" | undefined;
|
|
127
|
-
} | undefined;
|
|
128
|
-
}, {
|
|
129
|
-
vite?: {
|
|
130
|
-
environmentName?: string | undefined;
|
|
131
|
-
} | undefined;
|
|
132
|
-
hmr?: {
|
|
133
|
-
style?: "vite" | "webpack" | undefined;
|
|
134
|
-
} | undefined;
|
|
135
|
-
}>>;
|
|
136
|
-
}, "strip", z.ZodTypeAny, {
|
|
137
|
-
target: "react" | "solid" | "vue";
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
}, z.core.$strip>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export declare const getConfig: (inlineConfig: Partial<Config>, root: string) => {
|
|
111
|
+
target: "vue" | "react" | "solid";
|
|
138
112
|
routeFileIgnorePrefix: string;
|
|
139
113
|
routesDirectory: string;
|
|
140
114
|
quoteStyle: "single" | "double";
|
|
@@ -155,21 +129,11 @@ export declare const configSchema: z.ZodObject<{
|
|
|
155
129
|
enableRouteTreeFormatting: boolean;
|
|
156
130
|
tmpDir: string;
|
|
157
131
|
importRoutesUsingAbsolutePaths: boolean;
|
|
158
|
-
enableRouteGeneration?: boolean | undefined;
|
|
159
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
160
|
-
plugin?: {
|
|
161
|
-
vite?: {
|
|
162
|
-
environmentName?: string | undefined;
|
|
163
|
-
} | undefined;
|
|
164
|
-
hmr?: {
|
|
165
|
-
style?: "vite" | "webpack" | undefined;
|
|
166
|
-
} | undefined;
|
|
167
|
-
} | undefined;
|
|
168
132
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
169
133
|
routeFilePrefix?: string | undefined;
|
|
170
134
|
routeFileIgnorePattern?: string | undefined;
|
|
171
|
-
pathParamsAllowedCharacters?: ("
|
|
172
|
-
routeTreeFileFooter?: string[] | ((
|
|
135
|
+
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
136
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
173
137
|
autoCodeSplitting?: boolean | undefined;
|
|
174
138
|
customScaffolding?: {
|
|
175
139
|
routeTemplate?: string | undefined;
|
|
@@ -179,99 +143,16 @@ export declare const configSchema: z.ZodObject<{
|
|
|
179
143
|
enableCodeSplitting?: boolean | undefined;
|
|
180
144
|
} | undefined;
|
|
181
145
|
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
182
|
-
}, {
|
|
183
146
|
enableRouteGeneration?: boolean | undefined;
|
|
184
147
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
185
148
|
plugin?: {
|
|
186
|
-
vite?: {
|
|
187
|
-
environmentName?: string | undefined;
|
|
188
|
-
} | undefined;
|
|
189
149
|
hmr?: {
|
|
190
150
|
style?: "vite" | "webpack" | undefined;
|
|
191
151
|
} | undefined;
|
|
192
|
-
} | undefined;
|
|
193
|
-
target?: "react" | "solid" | "vue" | undefined;
|
|
194
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
195
|
-
routeFilePrefix?: string | undefined;
|
|
196
|
-
routeFileIgnorePrefix?: string | undefined;
|
|
197
|
-
routeFileIgnorePattern?: string | undefined;
|
|
198
|
-
routesDirectory?: string | undefined;
|
|
199
|
-
quoteStyle?: "single" | "double" | undefined;
|
|
200
|
-
semicolons?: boolean | undefined;
|
|
201
|
-
disableLogging?: boolean | undefined;
|
|
202
|
-
routeTreeFileHeader?: string[] | undefined;
|
|
203
|
-
indexToken?: string | RegExp | {
|
|
204
|
-
regex: string;
|
|
205
|
-
flags?: string | undefined;
|
|
206
|
-
} | undefined;
|
|
207
|
-
routeToken?: string | RegExp | {
|
|
208
|
-
regex: string;
|
|
209
|
-
flags?: string | undefined;
|
|
210
|
-
} | undefined;
|
|
211
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
212
|
-
generatedRouteTree?: string | undefined;
|
|
213
|
-
disableTypes?: boolean | undefined;
|
|
214
|
-
addExtensions?: string | boolean | undefined;
|
|
215
|
-
enableRouteTreeFormatting?: boolean | undefined;
|
|
216
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
217
|
-
autoCodeSplitting?: boolean | undefined;
|
|
218
|
-
customScaffolding?: {
|
|
219
|
-
routeTemplate?: string | undefined;
|
|
220
|
-
lazyRouteTemplate?: string | undefined;
|
|
221
|
-
} | undefined;
|
|
222
|
-
experimental?: {
|
|
223
|
-
enableCodeSplitting?: boolean | undefined;
|
|
224
|
-
} | undefined;
|
|
225
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
226
|
-
tmpDir?: string | undefined;
|
|
227
|
-
importRoutesUsingAbsolutePaths?: boolean | undefined;
|
|
228
|
-
}>;
|
|
229
|
-
export declare const getConfig: (inlineConfig: Partial<Config>, root: string) => {
|
|
230
|
-
target: "react" | "solid" | "vue";
|
|
231
|
-
routeFileIgnorePrefix: string;
|
|
232
|
-
routesDirectory: string;
|
|
233
|
-
quoteStyle: "single" | "double";
|
|
234
|
-
semicolons: boolean;
|
|
235
|
-
disableLogging: boolean;
|
|
236
|
-
routeTreeFileHeader: string[];
|
|
237
|
-
indexToken: string | RegExp | {
|
|
238
|
-
regex: string;
|
|
239
|
-
flags?: string | undefined;
|
|
240
|
-
};
|
|
241
|
-
routeToken: string | RegExp | {
|
|
242
|
-
regex: string;
|
|
243
|
-
flags?: string | undefined;
|
|
244
|
-
};
|
|
245
|
-
generatedRouteTree: string;
|
|
246
|
-
disableTypes: boolean;
|
|
247
|
-
addExtensions: string | boolean;
|
|
248
|
-
enableRouteTreeFormatting: boolean;
|
|
249
|
-
tmpDir: string;
|
|
250
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
251
|
-
enableRouteGeneration?: boolean | undefined;
|
|
252
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
253
|
-
plugin?: {
|
|
254
152
|
vite?: {
|
|
255
153
|
environmentName?: string | undefined;
|
|
256
154
|
} | undefined;
|
|
257
|
-
hmr?: {
|
|
258
|
-
style?: "vite" | "webpack" | undefined;
|
|
259
|
-
} | undefined;
|
|
260
155
|
} | undefined;
|
|
261
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
262
|
-
routeFilePrefix?: string | undefined;
|
|
263
|
-
routeFileIgnorePattern?: string | undefined;
|
|
264
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
265
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
266
|
-
autoCodeSplitting?: boolean | undefined;
|
|
267
|
-
customScaffolding?: {
|
|
268
|
-
routeTemplate?: string | undefined;
|
|
269
|
-
lazyRouteTemplate?: string | undefined;
|
|
270
|
-
} | undefined;
|
|
271
|
-
experimental?: {
|
|
272
|
-
enableCodeSplitting?: boolean | undefined;
|
|
273
|
-
} | undefined;
|
|
274
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
275
156
|
};
|
|
276
157
|
export type Config = z.infer<typeof configSchema>;
|
|
277
158
|
export type ConfigInput = z.input<typeof configSchema>;
|
|
@@ -2,7 +2,6 @@ require("../_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_config = require("./config.cjs");
|
|
3
3
|
const require_constants = require("./constants.cjs");
|
|
4
4
|
const require_utils = require("./utils.cjs");
|
|
5
|
-
const require_path_ids = require("./code-splitter/path-ids.cjs");
|
|
6
5
|
const require_compilers = require("./code-splitter/compilers.cjs");
|
|
7
6
|
const require_framework_plugins = require("./code-splitter/plugins/framework-plugins.cjs");
|
|
8
7
|
const require_router_plugin_context = require("./router-plugin-context.cjs");
|
|
@@ -66,7 +65,7 @@ function createRouterCodeSplitterPlugin(options = {}, routerPluginContext) {
|
|
|
66
65
|
if (fromCode.groupings !== void 0) {
|
|
67
66
|
const res = require_config.splitGroupingsSchema.safeParse(fromCode.groupings);
|
|
68
67
|
if (!res.success) {
|
|
69
|
-
const message = res.error.
|
|
68
|
+
const message = res.error.issues.map((e) => e.message).join(". ");
|
|
70
69
|
throw new Error(`The groupings for the route "${id}" are invalid.\n${message}`);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
@@ -74,7 +73,7 @@ function createRouterCodeSplitterPlugin(options = {}, routerPluginContext) {
|
|
|
74
73
|
if (pluginSplitBehavior) {
|
|
75
74
|
const res = require_config.splitGroupingsSchema.safeParse(pluginSplitBehavior);
|
|
76
75
|
if (!res.success) {
|
|
77
|
-
const message = res.error.
|
|
76
|
+
const message = res.error.issues.map((e) => e.message).join(". ");
|
|
78
77
|
throw new Error(`The groupings returned when using \`splitBehavior\` for the route "${id}" are invalid.\n${message}`);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
@@ -99,11 +98,11 @@ function createRouterCodeSplitterPlugin(options = {}, routerPluginContext) {
|
|
|
99
98
|
hmrStyle,
|
|
100
99
|
hmrRouteId: generatorNodeInfo.routeId,
|
|
101
100
|
sharedBindings: sharedBindings.size > 0 ? sharedBindings : void 0,
|
|
102
|
-
compilerPlugins: require_framework_plugins.getReferenceRouteCompilerPlugins({
|
|
101
|
+
compilerPlugins: [...require_framework_plugins.getReferenceRouteCompilerPlugins({
|
|
103
102
|
targetFramework: userConfig.target,
|
|
104
103
|
addHmr,
|
|
105
104
|
hmrStyle
|
|
106
|
-
})
|
|
105
|
+
}) ?? [], ...userConfig.codeSplittingOptions?.compilerPlugins ?? []]
|
|
107
106
|
});
|
|
108
107
|
if (compiledReferenceRoute === null) {
|
|
109
108
|
if (require_utils.debug) console.info(`No changes made to route "${id}", skipping code-splitting.`);
|
|
@@ -120,7 +119,7 @@ function createRouterCodeSplitterPlugin(options = {}, routerPluginContext) {
|
|
|
120
119
|
const [_, ...pathnameParts] = id.split("?");
|
|
121
120
|
const splitValue = new URLSearchParams(pathnameParts.join("?")).get(require_constants.tsrSplit);
|
|
122
121
|
if (!splitValue) throw new Error(`The split value for the virtual route "${id}" was not found.`);
|
|
123
|
-
const rawGrouping =
|
|
122
|
+
const rawGrouping = (0, _tanstack_router_utils.decodeIdentifier)(splitValue);
|
|
124
123
|
const grouping = [...new Set(rawGrouping)].filter((p) => require_constants.splitRouteIdentNodes.includes(p));
|
|
125
124
|
const baseId = id.split("?")[0];
|
|
126
125
|
const result = require_compilers.compileCodeSplitVirtualRoute({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-code-splitter-plugin.cjs","names":[],"sources":["../../../src/core/router-code-splitter-plugin.ts"],"sourcesContent":["/**\n * It is important to familiarize yourself with how the code-splitting works in this plugin.\n * https://github.com/TanStack/router/pull/3355\n */\n\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { logDiff } from '@tanstack/router-utils'\nimport { getConfig, splitGroupingsSchema } from './config'\nimport {\n compileCodeSplitReferenceRoute,\n compileCodeSplitSharedRoute,\n compileCodeSplitVirtualRoute,\n computeSharedBindings,\n detectCodeSplitGroupingsFromRoute,\n} from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport {\n defaultCodeSplitGroupings,\n splitRouteIdentNodes,\n tsrShared,\n tsrSplit,\n} from './constants'\nimport { decodeIdentifier } from './code-splitter/path-ids'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'\nimport type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\nimport type {\n UnpluginFactory,\n TransformResult as UnpluginTransformResult,\n} from 'unplugin'\n\nconst CODE_SPLITTER_PLUGIN_NAME =\n 'tanstack-router:code-splitter:compile-reference-file'\n\ntype TransformationPluginInfo = {\n pluginNames: Array<string>\n pkg: string\n usage: string\n}\n\n/**\n * JSX transformation plugins grouped by framework.\n * These plugins must come AFTER the TanStack Router plugin in the Vite config.\n */\nconst TRANSFORMATION_PLUGINS_BY_FRAMEWORK: Record<\n string,\n Array<TransformationPluginInfo>\n> = {\n react: [\n {\n // Babel-based React plugin\n pluginNames: ['vite:react-babel', 'vite:react-refresh'],\n pkg: '@vitejs/plugin-react',\n usage: 'react()',\n },\n {\n // SWC-based React plugin\n pluginNames: ['vite:react-swc', 'vite:react-swc:resolve-runtime'],\n pkg: '@vitejs/plugin-react-swc',\n usage: 'reactSwc()',\n },\n {\n // OXC-based React plugin (deprecated but should still be handled)\n pluginNames: ['vite:react-oxc:config', 'vite:react-oxc:refresh-runtime'],\n pkg: '@vitejs/plugin-react-oxc',\n usage: 'reactOxc()',\n },\n ],\n solid: [\n {\n pluginNames: ['solid'],\n pkg: 'vite-plugin-solid',\n usage: 'solid()',\n },\n ],\n}\n\nexport function createRouterCodeSplitterPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n const isProduction = process.env.NODE_ENV === 'production'\n // Map from normalized route file path → set of shared binding names.\n // Populated by the reference compiler, consumed by virtual and shared compilers.\n const sharedBindingsMap = new Map<string, Set<string>>()\n\n const getGlobalCodeSplitGroupings = () => {\n return (\n userConfig.codeSplittingOptions?.defaultBehavior ||\n defaultCodeSplitGroupings\n )\n }\n const getShouldSplitFn = () => {\n return userConfig.codeSplittingOptions?.splitBehavior\n }\n\n const handleCompilingReferenceFile = (\n code: string,\n id: string,\n generatorNodeInfo: GetRoutesByFileMapResultValue,\n ): UnpluginTransformResult => {\n if (debug) console.info('Compiling Route: ', id)\n\n const fromCode = detectCodeSplitGroupingsFromRoute({\n code,\n filename: id,\n })\n\n if (fromCode.groupings !== undefined) {\n const res = splitGroupingsSchema.safeParse(fromCode.groupings)\n if (!res.success) {\n const message = res.error.errors.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const userShouldSplitFn = getShouldSplitFn()\n\n const pluginSplitBehavior = userShouldSplitFn?.({\n routeId: generatorNodeInfo.routeId,\n }) as CodeSplitGroupings | undefined\n\n if (pluginSplitBehavior) {\n const res = splitGroupingsSchema.safeParse(pluginSplitBehavior)\n if (!res.success) {\n const message = res.error.errors.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings returned when using \\`splitBehavior\\` for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const splitGroupings: CodeSplitGroupings =\n fromCode.groupings ?? pluginSplitBehavior ?? getGlobalCodeSplitGroupings()\n\n // Compute shared bindings before compiling the reference route\n const sharedBindings = computeSharedBindings({\n code,\n filename: id,\n codeSplitGroupings: splitGroupings,\n })\n if (sharedBindings.size > 0) {\n sharedBindingsMap.set(id, sharedBindings)\n } else {\n sharedBindingsMap.delete(id)\n }\n\n const addHmr =\n (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n const compiledReferenceRoute = compileCodeSplitReferenceRoute({\n code,\n codeSplitGroupings: splitGroupings,\n targetFramework: userConfig.target,\n filename: id,\n id,\n deleteNodes: userConfig.codeSplittingOptions?.deleteNodes\n ? new Set(userConfig.codeSplittingOptions.deleteNodes)\n : undefined,\n addHmr,\n hmrStyle,\n hmrRouteId: generatorNodeInfo.routeId,\n sharedBindings: sharedBindings.size > 0 ? sharedBindings : undefined,\n compilerPlugins: getReferenceRouteCompilerPlugins({\n targetFramework: userConfig.target,\n addHmr,\n hmrStyle,\n }),\n })\n\n if (compiledReferenceRoute === null) {\n if (debug) {\n console.info(\n `No changes made to route \"${id}\", skipping code-splitting.`,\n )\n }\n return null\n }\n if (debug) {\n logDiff(code, compiledReferenceRoute.code)\n console.log('Output:\\n', compiledReferenceRoute.code + '\\n\\n')\n }\n\n return compiledReferenceRoute\n }\n\n const handleCompilingVirtualFile = (\n code: string,\n id: string,\n ): UnpluginTransformResult => {\n if (debug) console.info('Splitting Route: ', id)\n\n const [_, ...pathnameParts] = id.split('?')\n\n const searchParams = new URLSearchParams(pathnameParts.join('?'))\n const splitValue = searchParams.get(tsrSplit)\n\n if (!splitValue) {\n throw new Error(\n `The split value for the virtual route \"${id}\" was not found.`,\n )\n }\n\n const rawGrouping = decodeIdentifier(splitValue)\n const grouping = [...new Set(rawGrouping)].filter((p) =>\n splitRouteIdentNodes.includes(p as any),\n ) as Array<SplitRouteIdentNodes>\n\n const baseId = id.split('?')[0]!\n const resolvedSharedBindings = sharedBindingsMap.get(baseId)\n\n const result = compileCodeSplitVirtualRoute({\n code,\n filename: id,\n splitTargets: grouping,\n sharedBindings: resolvedSharedBindings,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n }\n\n return [\n {\n name: 'tanstack-router:code-splitter:compile-reference-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: {\n exclude: [tsrSplit, tsrShared],\n // this is necessary for webpack / rspack to avoid matching .html files\n include: /\\.(m|c)?(j|t)sx?$/,\n },\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const generatorFileInfo =\n routerPluginContext.routesByFile.get(normalizedId)\n if (generatorFileInfo) {\n return handleCompilingReferenceFile(\n code,\n normalizedId,\n generatorFileInfo,\n )\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n\n // Validate plugin order - router must come before JSX transformation plugins\n const routerPluginIndex = config.plugins.findIndex(\n (p) => p.name === CODE_SPLITTER_PLUGIN_NAME,\n )\n\n if (routerPluginIndex === -1) return\n\n const frameworkPlugins =\n TRANSFORMATION_PLUGINS_BY_FRAMEWORK[userConfig.target]\n if (!frameworkPlugins) return\n\n for (const transformPlugin of frameworkPlugins) {\n const transformPluginIndex = config.plugins.findIndex((p) =>\n transformPlugin.pluginNames.includes(p.name),\n )\n\n if (\n transformPluginIndex !== -1 &&\n transformPluginIndex < routerPluginIndex\n ) {\n throw new Error(\n `Plugin order error: '${transformPlugin.pkg}' is placed before '@tanstack/router-plugin'.\\n\\n` +\n `The TanStack Router plugin must come BEFORE JSX transformation plugins.\\n\\n` +\n `Please update your Vite config:\\n\\n` +\n ` plugins: [\\n` +\n ` tanstackRouter(),\\n` +\n ` ${transformPlugin.usage},\\n` +\n ` ]\\n`,\n )\n }\n }\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-virtual-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-split/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n return handleCompilingVirtualFile(code, normalizedId)\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-shared-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-shared/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n const [baseId] = normalizedId.split('?')\n\n if (!baseId) return null\n\n const sharedBindings = sharedBindingsMap.get(baseId)\n if (!sharedBindings || sharedBindings.size === 0) return null\n\n if (debug) console.info('Compiling Shared Module: ', id)\n\n const result = compileCodeSplitSharedRoute({\n code,\n sharedBindings,\n filename: normalizedId,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n ]\n}\n\nexport const unpluginRouterCodeSplitterFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterCodeSplitterPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,IAAM,4BACJ;;;;;AAYF,IAAM,sCAGF;CACF,OAAO;EACL;GAEE,aAAa,CAAC,oBAAoB,qBAAqB;GACvD,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,kBAAkB,iCAAiC;GACjE,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,yBAAyB,iCAAiC;GACxE,KAAK;GACL,OAAO;GACR;EACF;CACD,OAAO,CACL;EACE,aAAa,CAAC,QAAQ;EACtB,KAAK;EACL,OAAO;EACR,CACF;CACF;AAED,SAAgB,+BACd,UAAwD,EAAE,EAC1D,qBAC2E;CAC3E,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI;CAEJ,SAAS,iBAAiB;AACxB,MAAI,OAAO,YAAY,WACrB,cAAa,SAAS;MAEtB,cAAa,eAAA,UAAU,SAAS,KAAK;;CAGzC,MAAM,eAAA,QAAA,IAAA,aAAwC;CAG9C,MAAM,oCAAoB,IAAI,KAA0B;CAExD,MAAM,oCAAoC;AACxC,SACE,WAAW,sBAAsB,mBACjC,kBAAA;;CAGJ,MAAM,yBAAyB;AAC7B,SAAO,WAAW,sBAAsB;;CAG1C,MAAM,gCACJ,MACA,IACA,sBA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AS;GAET,WAAW;IACT,QAAQ,EACN,IAAI,cACL;IACD,QAAQ,MAAM,IAAI;KAChB,MAAM,OAAA,GAAA,SAAA,eAAoB,GAAG;AAC7B,SAAI,aAAa,OAAO,IAAI;KAC5B,MAAM,eAAe,cAAA,eAAA,GAAA,SAAA,eAA4B,IAAI,CAAC;KACtD,MAAM,CAAC,UAAU,aAAa,MAAM,IAAI;AAExC,SAAI,CAAC,OAAQ,QAAO;KAEpB,MAAM,iBAAiB,kBAAkB,IAAI,OAAO;AACpD,SAAI,CAAC,kBAAkB,eAAe,SAAS,EAAG,QAAO;AAEzD,SAAI,cAAA,MAAO,SAAQ,KAAK,6BAA6B,GAAG;KAExD,MAAM,SAAS,kBAAA,4BAA4B;MACzC;MACA;MACA,UAAU;MACX,CAAC;AAEF,SAAI,cAAA,OAAO;AACT,OAAA,GAAA,uBAAA,SAAQ,MAAM,OAAO,KAAK;AAC1B,cAAQ,IAAI,aAAa,OAAO,OAAO,OAAO;;AAGhD,YAAO;;IAEV;GAED,MAAM,EACJ,mBAAmB,aAAa;AAC9B,QAAI,WAAW,QAAQ,MAAM,gBAC3B,QAAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;AAEhE,WAAO;MAEV;GACF;EACF;;AAGH,IAAa,qCAER,UAAU,EAAE,KAAK;AACpB,QAAO,+BAA+B,SAAS,8BAAA,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"router-code-splitter-plugin.cjs","names":[],"sources":["../../../src/core/router-code-splitter-plugin.ts"],"sourcesContent":["/**\n * It is important to familiarize yourself with how the code-splitting works in this plugin.\n * https://github.com/TanStack/router/pull/3355\n */\n\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { decodeIdentifier, logDiff } from '@tanstack/router-utils'\nimport { getConfig, splitGroupingsSchema } from './config'\nimport {\n compileCodeSplitReferenceRoute,\n compileCodeSplitSharedRoute,\n compileCodeSplitVirtualRoute,\n computeSharedBindings,\n detectCodeSplitGroupingsFromRoute,\n} from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport {\n defaultCodeSplitGroupings,\n splitRouteIdentNodes,\n tsrShared,\n tsrSplit,\n} from './constants'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'\nimport type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\nimport type {\n UnpluginFactory,\n TransformResult as UnpluginTransformResult,\n} from 'unplugin'\n\nconst CODE_SPLITTER_PLUGIN_NAME =\n 'tanstack-router:code-splitter:compile-reference-file'\n\ntype TransformationPluginInfo = {\n pluginNames: Array<string>\n pkg: string\n usage: string\n}\n\n/**\n * JSX transformation plugins grouped by framework.\n * These plugins must come AFTER the TanStack Router plugin in the Vite config.\n */\nconst TRANSFORMATION_PLUGINS_BY_FRAMEWORK: Record<\n string,\n Array<TransformationPluginInfo>\n> = {\n react: [\n {\n // Babel-based React plugin\n pluginNames: ['vite:react-babel', 'vite:react-refresh'],\n pkg: '@vitejs/plugin-react',\n usage: 'react()',\n },\n {\n // SWC-based React plugin\n pluginNames: ['vite:react-swc', 'vite:react-swc:resolve-runtime'],\n pkg: '@vitejs/plugin-react-swc',\n usage: 'reactSwc()',\n },\n {\n // OXC-based React plugin (deprecated but should still be handled)\n pluginNames: ['vite:react-oxc:config', 'vite:react-oxc:refresh-runtime'],\n pkg: '@vitejs/plugin-react-oxc',\n usage: 'reactOxc()',\n },\n ],\n solid: [\n {\n pluginNames: ['solid'],\n pkg: 'vite-plugin-solid',\n usage: 'solid()',\n },\n ],\n}\n\nexport function createRouterCodeSplitterPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n const isProduction = process.env.NODE_ENV === 'production'\n // Map from normalized route file path → set of shared binding names.\n // Populated by the reference compiler, consumed by virtual and shared compilers.\n const sharedBindingsMap = new Map<string, Set<string>>()\n\n const getGlobalCodeSplitGroupings = () => {\n return (\n userConfig.codeSplittingOptions?.defaultBehavior ||\n defaultCodeSplitGroupings\n )\n }\n const getShouldSplitFn = () => {\n return userConfig.codeSplittingOptions?.splitBehavior\n }\n\n const handleCompilingReferenceFile = (\n code: string,\n id: string,\n generatorNodeInfo: GetRoutesByFileMapResultValue,\n ): UnpluginTransformResult => {\n if (debug) console.info('Compiling Route: ', id)\n\n const fromCode = detectCodeSplitGroupingsFromRoute({\n code,\n filename: id,\n })\n\n if (fromCode.groupings !== undefined) {\n const res = splitGroupingsSchema.safeParse(fromCode.groupings)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const userShouldSplitFn = getShouldSplitFn()\n\n const pluginSplitBehavior = userShouldSplitFn?.({\n routeId: generatorNodeInfo.routeId,\n }) as CodeSplitGroupings | undefined\n\n if (pluginSplitBehavior) {\n const res = splitGroupingsSchema.safeParse(pluginSplitBehavior)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings returned when using \\`splitBehavior\\` for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const splitGroupings: CodeSplitGroupings =\n fromCode.groupings ?? pluginSplitBehavior ?? getGlobalCodeSplitGroupings()\n\n // Compute shared bindings before compiling the reference route\n const sharedBindings = computeSharedBindings({\n code,\n filename: id,\n codeSplitGroupings: splitGroupings,\n })\n if (sharedBindings.size > 0) {\n sharedBindingsMap.set(id, sharedBindings)\n } else {\n sharedBindingsMap.delete(id)\n }\n\n const addHmr =\n (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n const compiledReferenceRoute = compileCodeSplitReferenceRoute({\n code,\n codeSplitGroupings: splitGroupings,\n targetFramework: userConfig.target,\n filename: id,\n id,\n deleteNodes: userConfig.codeSplittingOptions?.deleteNodes\n ? new Set(userConfig.codeSplittingOptions.deleteNodes)\n : undefined,\n addHmr,\n hmrStyle,\n hmrRouteId: generatorNodeInfo.routeId,\n sharedBindings: sharedBindings.size > 0 ? sharedBindings : undefined,\n compilerPlugins: [\n ...(getReferenceRouteCompilerPlugins({\n targetFramework: userConfig.target,\n addHmr,\n hmrStyle,\n }) ?? []),\n ...(userConfig.codeSplittingOptions?.compilerPlugins ?? []),\n ],\n })\n\n if (compiledReferenceRoute === null) {\n if (debug) {\n console.info(\n `No changes made to route \"${id}\", skipping code-splitting.`,\n )\n }\n return null\n }\n if (debug) {\n logDiff(code, compiledReferenceRoute.code)\n console.log('Output:\\n', compiledReferenceRoute.code + '\\n\\n')\n }\n\n return compiledReferenceRoute\n }\n\n const handleCompilingVirtualFile = (\n code: string,\n id: string,\n ): UnpluginTransformResult => {\n if (debug) console.info('Splitting Route: ', id)\n\n const [_, ...pathnameParts] = id.split('?')\n\n const searchParams = new URLSearchParams(pathnameParts.join('?'))\n const splitValue = searchParams.get(tsrSplit)\n\n if (!splitValue) {\n throw new Error(\n `The split value for the virtual route \"${id}\" was not found.`,\n )\n }\n\n const rawGrouping = decodeIdentifier(splitValue)\n const grouping = [...new Set(rawGrouping)].filter((p) =>\n splitRouteIdentNodes.includes(p as any),\n ) as Array<SplitRouteIdentNodes>\n\n const baseId = id.split('?')[0]!\n const resolvedSharedBindings = sharedBindingsMap.get(baseId)\n\n const result = compileCodeSplitVirtualRoute({\n code,\n filename: id,\n splitTargets: grouping,\n sharedBindings: resolvedSharedBindings,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n }\n\n return [\n {\n name: 'tanstack-router:code-splitter:compile-reference-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: {\n exclude: [tsrSplit, tsrShared],\n // this is necessary for webpack / rspack to avoid matching .html files\n include: /\\.(m|c)?(j|t)sx?$/,\n },\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const generatorFileInfo =\n routerPluginContext.routesByFile.get(normalizedId)\n if (generatorFileInfo) {\n return handleCompilingReferenceFile(\n code,\n normalizedId,\n generatorFileInfo,\n )\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n\n // Validate plugin order - router must come before JSX transformation plugins\n const routerPluginIndex = config.plugins.findIndex(\n (p) => p.name === CODE_SPLITTER_PLUGIN_NAME,\n )\n\n if (routerPluginIndex === -1) return\n\n const frameworkPlugins =\n TRANSFORMATION_PLUGINS_BY_FRAMEWORK[userConfig.target]\n if (!frameworkPlugins) return\n\n for (const transformPlugin of frameworkPlugins) {\n const transformPluginIndex = config.plugins.findIndex((p) =>\n transformPlugin.pluginNames.includes(p.name),\n )\n\n if (\n transformPluginIndex !== -1 &&\n transformPluginIndex < routerPluginIndex\n ) {\n throw new Error(\n `Plugin order error: '${transformPlugin.pkg}' is placed before '@tanstack/router-plugin'.\\n\\n` +\n `The TanStack Router plugin must come BEFORE JSX transformation plugins.\\n\\n` +\n `Please update your Vite config:\\n\\n` +\n ` plugins: [\\n` +\n ` tanstackRouter(),\\n` +\n ` ${transformPlugin.usage},\\n` +\n ` ]\\n`,\n )\n }\n }\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-virtual-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-split/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n return handleCompilingVirtualFile(code, normalizedId)\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-shared-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-shared/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n const [baseId] = normalizedId.split('?')\n\n if (!baseId) return null\n\n const sharedBindings = sharedBindingsMap.get(baseId)\n if (!sharedBindings || sharedBindings.size === 0) return null\n\n if (debug) console.info('Compiling Shared Module: ', id)\n\n const result = compileCodeSplitSharedRoute({\n code,\n sharedBindings,\n filename: normalizedId,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n ]\n}\n\nexport const unpluginRouterCodeSplitterFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterCodeSplitterPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,IAAM,4BACJ;;;;;AAYF,IAAM,sCAGF;CACF,OAAO;EACL;GAEE,aAAa,CAAC,oBAAoB,qBAAqB;GACvD,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,kBAAkB,iCAAiC;GACjE,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,yBAAyB,iCAAiC;GACxE,KAAK;GACL,OAAO;GACR;EACF;CACD,OAAO,CACL;EACE,aAAa,CAAC,QA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AAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;AAEhE,WAAO;MAEV;GACF;EACF;;AAGH,IAAa,qCAER,UAAU,EAAE,KAAK;AACpB,QAAO,+BAA+B,SAAS,8BAAA,2BAA2B,CAAC"}
|
package/dist/cjs/esbuild.d.cts
CHANGED
|
@@ -31,7 +31,7 @@ declare const TanStackRouterCodeSplitterEsbuild: (options?: RouterPluginOptions,
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare const TanStackRouterEsbuild: (options?: Partial<{
|
|
34
|
-
target: "
|
|
34
|
+
target: "vue" | "react" | "solid";
|
|
35
35
|
routeFileIgnorePrefix: string;
|
|
36
36
|
routesDirectory: string;
|
|
37
37
|
quoteStyle: "single" | "double";
|
|
@@ -52,21 +52,11 @@ declare const TanStackRouterEsbuild: (options?: Partial<{
|
|
|
52
52
|
enableRouteTreeFormatting: boolean;
|
|
53
53
|
tmpDir: string;
|
|
54
54
|
importRoutesUsingAbsolutePaths: boolean;
|
|
55
|
-
enableRouteGeneration?: boolean | undefined;
|
|
56
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
57
|
-
plugin?: {
|
|
58
|
-
vite?: {
|
|
59
|
-
environmentName?: string | undefined;
|
|
60
|
-
} | undefined;
|
|
61
|
-
hmr?: {
|
|
62
|
-
style?: "vite" | "webpack" | undefined;
|
|
63
|
-
} | undefined;
|
|
64
|
-
} | undefined;
|
|
65
55
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
66
56
|
routeFilePrefix?: string | undefined;
|
|
67
57
|
routeFileIgnorePattern?: string | undefined;
|
|
68
|
-
pathParamsAllowedCharacters?: ("
|
|
69
|
-
routeTreeFileFooter?: string[] | ((
|
|
58
|
+
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
59
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
70
60
|
autoCodeSplitting?: boolean | undefined;
|
|
71
61
|
customScaffolding?: {
|
|
72
62
|
routeTemplate?: string | undefined;
|
|
@@ -76,9 +66,19 @@ declare const TanStackRouterEsbuild: (options?: Partial<{
|
|
|
76
66
|
enableCodeSplitting?: boolean | undefined;
|
|
77
67
|
} | undefined;
|
|
78
68
|
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
69
|
+
enableRouteGeneration?: boolean | undefined;
|
|
70
|
+
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
71
|
+
plugin?: {
|
|
72
|
+
hmr?: {
|
|
73
|
+
style?: "vite" | "webpack" | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
vite?: {
|
|
76
|
+
environmentName?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
} | undefined;
|
|
79
79
|
} | (() => Config)> | undefined) => import('unplugin').EsbuildPlugin;
|
|
80
80
|
declare const tanstackRouter: (options?: Partial<{
|
|
81
|
-
target: "
|
|
81
|
+
target: "vue" | "react" | "solid";
|
|
82
82
|
routeFileIgnorePrefix: string;
|
|
83
83
|
routesDirectory: string;
|
|
84
84
|
quoteStyle: "single" | "double";
|
|
@@ -99,21 +99,11 @@ declare const tanstackRouter: (options?: Partial<{
|
|
|
99
99
|
enableRouteTreeFormatting: boolean;
|
|
100
100
|
tmpDir: string;
|
|
101
101
|
importRoutesUsingAbsolutePaths: boolean;
|
|
102
|
-
enableRouteGeneration?: boolean | undefined;
|
|
103
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
104
|
-
plugin?: {
|
|
105
|
-
vite?: {
|
|
106
|
-
environmentName?: string | undefined;
|
|
107
|
-
} | undefined;
|
|
108
|
-
hmr?: {
|
|
109
|
-
style?: "vite" | "webpack" | undefined;
|
|
110
|
-
} | undefined;
|
|
111
|
-
} | undefined;
|
|
112
102
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
113
103
|
routeFilePrefix?: string | undefined;
|
|
114
104
|
routeFileIgnorePattern?: string | undefined;
|
|
115
|
-
pathParamsAllowedCharacters?: ("
|
|
116
|
-
routeTreeFileFooter?: string[] | ((
|
|
105
|
+
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
106
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
117
107
|
autoCodeSplitting?: boolean | undefined;
|
|
118
108
|
customScaffolding?: {
|
|
119
109
|
routeTemplate?: string | undefined;
|
|
@@ -123,6 +113,16 @@ declare const tanstackRouter: (options?: Partial<{
|
|
|
123
113
|
enableCodeSplitting?: boolean | undefined;
|
|
124
114
|
} | undefined;
|
|
125
115
|
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
116
|
+
enableRouteGeneration?: boolean | undefined;
|
|
117
|
+
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
118
|
+
plugin?: {
|
|
119
|
+
hmr?: {
|
|
120
|
+
style?: "vite" | "webpack" | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
vite?: {
|
|
123
|
+
environmentName?: string | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
} | undefined;
|
|
126
126
|
} | (() => Config)> | undefined) => import('unplugin').EsbuildPlugin;
|
|
127
127
|
export default TanStackRouterEsbuild;
|
|
128
128
|
export { configSchema, TanStackRouterGeneratorEsbuild, TanStackRouterCodeSplitterEsbuild, TanStackRouterEsbuild, tanstackRouter, };
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_config = require("./core/config.cjs");
|
|
3
3
|
const require_constants = require("./core/constants.cjs");
|
|
4
|
+
const require_utils = require("./core/utils.cjs");
|
|
4
5
|
const require_router_plugin_context = require("./core/router-plugin-context.cjs");
|
|
5
6
|
const require_router_code_splitter_plugin = require("./core/router-code-splitter-plugin.cjs");
|
|
6
7
|
const require_router_generator_plugin = require("./core/router-generator-plugin.cjs");
|
|
@@ -8,6 +9,7 @@ exports.configSchema = require_config.configSchema;
|
|
|
8
9
|
exports.createRouterPluginContext = require_router_plugin_context.createRouterPluginContext;
|
|
9
10
|
exports.defaultCodeSplitGroupings = require_constants.defaultCodeSplitGroupings;
|
|
10
11
|
exports.getConfig = require_config.getConfig;
|
|
12
|
+
exports.getObjectPropertyKeyName = require_utils.getObjectPropertyKeyName;
|
|
11
13
|
exports.splitRouteIdentNodes = require_constants.splitRouteIdentNodes;
|
|
12
14
|
exports.tsrSplit = require_constants.tsrSplit;
|
|
13
15
|
exports.unpluginRouterCodeSplitterFactory = require_router_code_splitter_plugin.unpluginRouterCodeSplitterFactory;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -4,4 +4,6 @@ export { unpluginRouterGeneratorFactory } from './core/router-generator-plugin.c
|
|
|
4
4
|
export { createRouterPluginContext } from './core/router-plugin-context.cjs';
|
|
5
5
|
export type { Config, ConfigInput, ConfigOutput, CodeSplittingOptions, DeletableNodes, HmrOptions, } from './core/config.cjs';
|
|
6
6
|
export type { RouterPluginContext } from './core/router-plugin-context.cjs';
|
|
7
|
+
export { getObjectPropertyKeyName } from './core/utils.cjs';
|
|
8
|
+
export type { ReferenceRouteCompilerPlugin, ReferenceRouteCompilerPluginContext, } from './core/code-splitter/plugins.cjs';
|
|
7
9
|
export { tsrSplit, splitRouteIdentNodes, defaultCodeSplitGroupings, } from './core/constants.cjs';
|
package/dist/cjs/vite.d.cts
CHANGED
|
@@ -31,7 +31,7 @@ declare const tanStackRouterCodeSplitter: (options?: RouterPluginOptions, router
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare const tanstackRouter: (options?: Partial<{
|
|
34
|
-
target: "
|
|
34
|
+
target: "vue" | "react" | "solid";
|
|
35
35
|
routeFileIgnorePrefix: string;
|
|
36
36
|
routesDirectory: string;
|
|
37
37
|
quoteStyle: "single" | "double";
|
|
@@ -52,21 +52,11 @@ declare const tanstackRouter: (options?: Partial<{
|
|
|
52
52
|
enableRouteTreeFormatting: boolean;
|
|
53
53
|
tmpDir: string;
|
|
54
54
|
importRoutesUsingAbsolutePaths: boolean;
|
|
55
|
-
enableRouteGeneration?: boolean | undefined;
|
|
56
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
57
|
-
plugin?: {
|
|
58
|
-
vite?: {
|
|
59
|
-
environmentName?: string | undefined;
|
|
60
|
-
} | undefined;
|
|
61
|
-
hmr?: {
|
|
62
|
-
style?: "vite" | "webpack" | undefined;
|
|
63
|
-
} | undefined;
|
|
64
|
-
} | undefined;
|
|
65
55
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
66
56
|
routeFilePrefix?: string | undefined;
|
|
67
57
|
routeFileIgnorePattern?: string | undefined;
|
|
68
|
-
pathParamsAllowedCharacters?: ("
|
|
69
|
-
routeTreeFileFooter?: string[] | ((
|
|
58
|
+
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
59
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
70
60
|
autoCodeSplitting?: boolean | undefined;
|
|
71
61
|
customScaffolding?: {
|
|
72
62
|
routeTemplate?: string | undefined;
|
|
@@ -76,12 +66,22 @@ declare const tanstackRouter: (options?: Partial<{
|
|
|
76
66
|
enableCodeSplitting?: boolean | undefined;
|
|
77
67
|
} | undefined;
|
|
78
68
|
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
69
|
+
enableRouteGeneration?: boolean | undefined;
|
|
70
|
+
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
71
|
+
plugin?: {
|
|
72
|
+
hmr?: {
|
|
73
|
+
style?: "vite" | "webpack" | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
vite?: {
|
|
76
|
+
environmentName?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
} | undefined;
|
|
79
79
|
} | (() => Config)> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
|
|
80
80
|
/**
|
|
81
81
|
* @deprecated Use `tanstackRouter` instead.
|
|
82
82
|
*/
|
|
83
83
|
declare const TanStackRouterVite: (options?: Partial<{
|
|
84
|
-
target: "
|
|
84
|
+
target: "vue" | "react" | "solid";
|
|
85
85
|
routeFileIgnorePrefix: string;
|
|
86
86
|
routesDirectory: string;
|
|
87
87
|
quoteStyle: "single" | "double";
|
|
@@ -102,21 +102,11 @@ declare const TanStackRouterVite: (options?: Partial<{
|
|
|
102
102
|
enableRouteTreeFormatting: boolean;
|
|
103
103
|
tmpDir: string;
|
|
104
104
|
importRoutesUsingAbsolutePaths: boolean;
|
|
105
|
-
enableRouteGeneration?: boolean | undefined;
|
|
106
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
107
|
-
plugin?: {
|
|
108
|
-
vite?: {
|
|
109
|
-
environmentName?: string | undefined;
|
|
110
|
-
} | undefined;
|
|
111
|
-
hmr?: {
|
|
112
|
-
style?: "vite" | "webpack" | undefined;
|
|
113
|
-
} | undefined;
|
|
114
|
-
} | undefined;
|
|
115
105
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
116
106
|
routeFilePrefix?: string | undefined;
|
|
117
107
|
routeFileIgnorePattern?: string | undefined;
|
|
118
|
-
pathParamsAllowedCharacters?: ("
|
|
119
|
-
routeTreeFileFooter?: string[] | ((
|
|
108
|
+
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
109
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
120
110
|
autoCodeSplitting?: boolean | undefined;
|
|
121
111
|
customScaffolding?: {
|
|
122
112
|
routeTemplate?: string | undefined;
|
|
@@ -126,6 +116,16 @@ declare const TanStackRouterVite: (options?: Partial<{
|
|
|
126
116
|
enableCodeSplitting?: boolean | undefined;
|
|
127
117
|
} | undefined;
|
|
128
118
|
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
119
|
+
enableRouteGeneration?: boolean | undefined;
|
|
120
|
+
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
121
|
+
plugin?: {
|
|
122
|
+
hmr?: {
|
|
123
|
+
style?: "vite" | "webpack" | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
vite?: {
|
|
126
|
+
environmentName?: string | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
} | undefined;
|
|
129
129
|
} | (() => Config)> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
|
|
130
130
|
export default tanstackRouter;
|
|
131
131
|
export { configSchema, getConfig, tanStackRouterCodeSplitter, tanstackRouterGenerator, TanStackRouterVite, tanstackRouter, };
|