@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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
7
|
-
import { logDiff } from '@tanstack/router-utils'
|
|
7
|
+
import { decodeIdentifier, logDiff } from '@tanstack/router-utils'
|
|
8
8
|
import { getConfig, splitGroupingsSchema } from './config'
|
|
9
9
|
import {
|
|
10
10
|
compileCodeSplitReferenceRoute,
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
tsrShared,
|
|
21
21
|
tsrSplit,
|
|
22
22
|
} from './constants'
|
|
23
|
-
import { decodeIdentifier } from './code-splitter/path-ids'
|
|
24
23
|
import { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'
|
|
25
24
|
import { createRouterPluginContext } from './router-plugin-context'
|
|
26
25
|
import type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'
|
|
@@ -122,7 +121,7 @@ export function createRouterCodeSplitterPlugin(
|
|
|
122
121
|
if (fromCode.groupings !== undefined) {
|
|
123
122
|
const res = splitGroupingsSchema.safeParse(fromCode.groupings)
|
|
124
123
|
if (!res.success) {
|
|
125
|
-
const message = res.error.
|
|
124
|
+
const message = res.error.issues.map((e) => e.message).join('. ')
|
|
126
125
|
throw new Error(
|
|
127
126
|
`The groupings for the route "${id}" are invalid.\n${message}`,
|
|
128
127
|
)
|
|
@@ -138,7 +137,7 @@ export function createRouterCodeSplitterPlugin(
|
|
|
138
137
|
if (pluginSplitBehavior) {
|
|
139
138
|
const res = splitGroupingsSchema.safeParse(pluginSplitBehavior)
|
|
140
139
|
if (!res.success) {
|
|
141
|
-
const message = res.error.
|
|
140
|
+
const message = res.error.issues.map((e) => e.message).join('. ')
|
|
142
141
|
throw new Error(
|
|
143
142
|
`The groupings returned when using \`splitBehavior\` for the route "${id}" are invalid.\n${message}`,
|
|
144
143
|
)
|
|
@@ -177,11 +176,14 @@ export function createRouterCodeSplitterPlugin(
|
|
|
177
176
|
hmrStyle,
|
|
178
177
|
hmrRouteId: generatorNodeInfo.routeId,
|
|
179
178
|
sharedBindings: sharedBindings.size > 0 ? sharedBindings : undefined,
|
|
180
|
-
compilerPlugins:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
compilerPlugins: [
|
|
180
|
+
...(getReferenceRouteCompilerPlugins({
|
|
181
|
+
targetFramework: userConfig.target,
|
|
182
|
+
addHmr,
|
|
183
|
+
hmrStyle,
|
|
184
|
+
}) ?? []),
|
|
185
|
+
...(userConfig.codeSplittingOptions?.compilerPlugins ?? []),
|
|
186
|
+
],
|
|
185
187
|
})
|
|
186
188
|
|
|
187
189
|
if (compiledReferenceRoute === null) {
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,11 @@ export type {
|
|
|
11
11
|
HmrOptions,
|
|
12
12
|
} from './core/config'
|
|
13
13
|
export type { RouterPluginContext } from './core/router-plugin-context'
|
|
14
|
+
export { getObjectPropertyKeyName } from './core/utils'
|
|
15
|
+
export type {
|
|
16
|
+
ReferenceRouteCompilerPlugin,
|
|
17
|
+
ReferenceRouteCompilerPluginContext,
|
|
18
|
+
} from './core/code-splitter/plugins'
|
|
14
19
|
export {
|
|
15
20
|
tsrSplit,
|
|
16
21
|
splitRouteIdentNodes,
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//#region src/core/code-splitter/path-ids.ts
|
|
2
|
-
function createIdentifier(strings) {
|
|
3
|
-
if (strings.length === 0) throw new Error("Cannot create an identifier from an empty array");
|
|
4
|
-
let safeString = [...strings].sort().join("---").replace(/\//g, "--slash--");
|
|
5
|
-
safeString = safeString.replace(/\\/g, "--backslash--");
|
|
6
|
-
safeString = safeString.replace(/\?/g, "--question--");
|
|
7
|
-
safeString = safeString.replace(/%/g, "--percent--");
|
|
8
|
-
safeString = safeString.replace(/#/g, "--hash--");
|
|
9
|
-
safeString = safeString.replace(/\+/g, "--plus--");
|
|
10
|
-
safeString = safeString.replace(/=/g, "--equals--");
|
|
11
|
-
safeString = safeString.replace(/&/g, "--ampersand--");
|
|
12
|
-
safeString = safeString.replace(/\s/g, "_");
|
|
13
|
-
return safeString;
|
|
14
|
-
}
|
|
15
|
-
function decodeIdentifier(identifier) {
|
|
16
|
-
if (!identifier) return [];
|
|
17
|
-
let combinedString = identifier.replace(/--slash--/g, "/");
|
|
18
|
-
combinedString = combinedString.replace(/--backslash--/g, "\\");
|
|
19
|
-
combinedString = combinedString.replace(/--question--/g, "?");
|
|
20
|
-
combinedString = combinedString.replace(/--percent--/g, "%");
|
|
21
|
-
combinedString = combinedString.replace(/--hash--/g, "#");
|
|
22
|
-
combinedString = combinedString.replace(/--plus--/g, "+");
|
|
23
|
-
combinedString = combinedString.replace(/--equals--/g, "=");
|
|
24
|
-
combinedString = combinedString.replace(/--ampersand--/g, "&");
|
|
25
|
-
combinedString = combinedString.replace(/_/g, " ");
|
|
26
|
-
return combinedString.split("---");
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
exports.createIdentifier = createIdentifier;
|
|
30
|
-
exports.decodeIdentifier = decodeIdentifier;
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=path-ids.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-ids.cjs","names":[],"sources":["../../../../src/core/code-splitter/path-ids.ts"],"sourcesContent":["export function createIdentifier(strings: Array<string>): string {\n if (strings.length === 0) {\n throw new Error('Cannot create an identifier from an empty array')\n }\n\n const sortedStrings = [...strings].sort()\n const combinedString = sortedStrings.join('---') // Delimiter\n\n // Replace unsafe characters\n let safeString = combinedString.replace(/\\//g, '--slash--')\n safeString = safeString.replace(/\\\\/g, '--backslash--')\n safeString = safeString.replace(/\\?/g, '--question--')\n safeString = safeString.replace(/%/g, '--percent--')\n safeString = safeString.replace(/#/g, '--hash--')\n safeString = safeString.replace(/\\+/g, '--plus--')\n safeString = safeString.replace(/=/g, '--equals--')\n safeString = safeString.replace(/&/g, '--ampersand--')\n safeString = safeString.replace(/\\s/g, '_') // Replace spaces with underscores\n\n return safeString\n}\n\nexport function decodeIdentifier(identifier: string): Array<string> {\n if (!identifier) {\n return []\n }\n\n let combinedString = identifier.replace(/--slash--/g, '/')\n combinedString = combinedString.replace(/--backslash--/g, '\\\\')\n combinedString = combinedString.replace(/--question--/g, '?')\n combinedString = combinedString.replace(/--percent--/g, '%')\n combinedString = combinedString.replace(/--hash--/g, '#')\n combinedString = combinedString.replace(/--plus--/g, '+')\n combinedString = combinedString.replace(/--equals--/g, '=')\n combinedString = combinedString.replace(/--ampersand--/g, '&')\n combinedString = combinedString.replace(/_/g, ' ') // Restore spaces\n\n return combinedString.split('---')\n}\n"],"mappings":";AAAA,SAAgB,iBAAiB,SAAgC;AAC/D,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,kDAAkD;CAOpE,IAAI,aAJkB,CAAC,GAAG,QAAQ,CAAC,MAAM,CACJ,KAAK,MAAM,CAGhB,QAAQ,OAAO,YAAY;AAC3D,cAAa,WAAW,QAAQ,OAAO,gBAAgB;AACvD,cAAa,WAAW,QAAQ,OAAO,eAAe;AACtD,cAAa,WAAW,QAAQ,MAAM,cAAc;AACpD,cAAa,WAAW,QAAQ,MAAM,WAAW;AACjD,cAAa,WAAW,QAAQ,OAAO,WAAW;AAClD,cAAa,WAAW,QAAQ,MAAM,aAAa;AACnD,cAAa,WAAW,QAAQ,MAAM,gBAAgB;AACtD,cAAa,WAAW,QAAQ,OAAO,IAAI;AAE3C,QAAO;;AAGT,SAAgB,iBAAiB,YAAmC;AAClE,KAAI,CAAC,WACH,QAAO,EAAE;CAGX,IAAI,iBAAiB,WAAW,QAAQ,cAAc,IAAI;AAC1D,kBAAiB,eAAe,QAAQ,kBAAkB,KAAK;AAC/D,kBAAiB,eAAe,QAAQ,iBAAiB,IAAI;AAC7D,kBAAiB,eAAe,QAAQ,gBAAgB,IAAI;AAC5D,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,eAAe,IAAI;AAC3D,kBAAiB,eAAe,QAAQ,kBAAkB,IAAI;AAC9D,kBAAiB,eAAe,QAAQ,MAAM,IAAI;AAElD,QAAO,eAAe,MAAM,MAAM"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/core/code-splitter/path-ids.ts
|
|
2
|
-
function createIdentifier(strings) {
|
|
3
|
-
if (strings.length === 0) throw new Error("Cannot create an identifier from an empty array");
|
|
4
|
-
let safeString = [...strings].sort().join("---").replace(/\//g, "--slash--");
|
|
5
|
-
safeString = safeString.replace(/\\/g, "--backslash--");
|
|
6
|
-
safeString = safeString.replace(/\?/g, "--question--");
|
|
7
|
-
safeString = safeString.replace(/%/g, "--percent--");
|
|
8
|
-
safeString = safeString.replace(/#/g, "--hash--");
|
|
9
|
-
safeString = safeString.replace(/\+/g, "--plus--");
|
|
10
|
-
safeString = safeString.replace(/=/g, "--equals--");
|
|
11
|
-
safeString = safeString.replace(/&/g, "--ampersand--");
|
|
12
|
-
safeString = safeString.replace(/\s/g, "_");
|
|
13
|
-
return safeString;
|
|
14
|
-
}
|
|
15
|
-
function decodeIdentifier(identifier) {
|
|
16
|
-
if (!identifier) return [];
|
|
17
|
-
let combinedString = identifier.replace(/--slash--/g, "/");
|
|
18
|
-
combinedString = combinedString.replace(/--backslash--/g, "\\");
|
|
19
|
-
combinedString = combinedString.replace(/--question--/g, "?");
|
|
20
|
-
combinedString = combinedString.replace(/--percent--/g, "%");
|
|
21
|
-
combinedString = combinedString.replace(/--hash--/g, "#");
|
|
22
|
-
combinedString = combinedString.replace(/--plus--/g, "+");
|
|
23
|
-
combinedString = combinedString.replace(/--equals--/g, "=");
|
|
24
|
-
combinedString = combinedString.replace(/--ampersand--/g, "&");
|
|
25
|
-
combinedString = combinedString.replace(/_/g, " ");
|
|
26
|
-
return combinedString.split("---");
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { createIdentifier, decodeIdentifier };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=path-ids.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-ids.js","names":[],"sources":["../../../../src/core/code-splitter/path-ids.ts"],"sourcesContent":["export function createIdentifier(strings: Array<string>): string {\n if (strings.length === 0) {\n throw new Error('Cannot create an identifier from an empty array')\n }\n\n const sortedStrings = [...strings].sort()\n const combinedString = sortedStrings.join('---') // Delimiter\n\n // Replace unsafe characters\n let safeString = combinedString.replace(/\\//g, '--slash--')\n safeString = safeString.replace(/\\\\/g, '--backslash--')\n safeString = safeString.replace(/\\?/g, '--question--')\n safeString = safeString.replace(/%/g, '--percent--')\n safeString = safeString.replace(/#/g, '--hash--')\n safeString = safeString.replace(/\\+/g, '--plus--')\n safeString = safeString.replace(/=/g, '--equals--')\n safeString = safeString.replace(/&/g, '--ampersand--')\n safeString = safeString.replace(/\\s/g, '_') // Replace spaces with underscores\n\n return safeString\n}\n\nexport function decodeIdentifier(identifier: string): Array<string> {\n if (!identifier) {\n return []\n }\n\n let combinedString = identifier.replace(/--slash--/g, '/')\n combinedString = combinedString.replace(/--backslash--/g, '\\\\')\n combinedString = combinedString.replace(/--question--/g, '?')\n combinedString = combinedString.replace(/--percent--/g, '%')\n combinedString = combinedString.replace(/--hash--/g, '#')\n combinedString = combinedString.replace(/--plus--/g, '+')\n combinedString = combinedString.replace(/--equals--/g, '=')\n combinedString = combinedString.replace(/--ampersand--/g, '&')\n combinedString = combinedString.replace(/_/g, ' ') // Restore spaces\n\n return combinedString.split('---')\n}\n"],"mappings":";AAAA,SAAgB,iBAAiB,SAAgC;AAC/D,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,kDAAkD;CAOpE,IAAI,aAJkB,CAAC,GAAG,QAAQ,CAAC,MAAM,CACJ,KAAK,MAAM,CAGhB,QAAQ,OAAO,YAAY;AAC3D,cAAa,WAAW,QAAQ,OAAO,gBAAgB;AACvD,cAAa,WAAW,QAAQ,OAAO,eAAe;AACtD,cAAa,WAAW,QAAQ,MAAM,cAAc;AACpD,cAAa,WAAW,QAAQ,MAAM,WAAW;AACjD,cAAa,WAAW,QAAQ,OAAO,WAAW;AAClD,cAAa,WAAW,QAAQ,MAAM,aAAa;AACnD,cAAa,WAAW,QAAQ,MAAM,gBAAgB;AACtD,cAAa,WAAW,QAAQ,OAAO,IAAI;AAE3C,QAAO;;AAGT,SAAgB,iBAAiB,YAAmC;AAClE,KAAI,CAAC,WACH,QAAO,EAAE;CAGX,IAAI,iBAAiB,WAAW,QAAQ,cAAc,IAAI;AAC1D,kBAAiB,eAAe,QAAQ,kBAAkB,KAAK;AAC/D,kBAAiB,eAAe,QAAQ,iBAAiB,IAAI;AAC7D,kBAAiB,eAAe,QAAQ,gBAAgB,IAAI;AAC5D,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,eAAe,IAAI;AAC3D,kBAAiB,eAAe,QAAQ,kBAAkB,IAAI;AAC9D,kBAAiB,eAAe,QAAQ,MAAM,IAAI;AAElD,QAAO,eAAe,MAAM,MAAM"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export function createIdentifier(strings: Array<string>): string {
|
|
2
|
-
if (strings.length === 0) {
|
|
3
|
-
throw new Error('Cannot create an identifier from an empty array')
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const sortedStrings = [...strings].sort()
|
|
7
|
-
const combinedString = sortedStrings.join('---') // Delimiter
|
|
8
|
-
|
|
9
|
-
// Replace unsafe characters
|
|
10
|
-
let safeString = combinedString.replace(/\//g, '--slash--')
|
|
11
|
-
safeString = safeString.replace(/\\/g, '--backslash--')
|
|
12
|
-
safeString = safeString.replace(/\?/g, '--question--')
|
|
13
|
-
safeString = safeString.replace(/%/g, '--percent--')
|
|
14
|
-
safeString = safeString.replace(/#/g, '--hash--')
|
|
15
|
-
safeString = safeString.replace(/\+/g, '--plus--')
|
|
16
|
-
safeString = safeString.replace(/=/g, '--equals--')
|
|
17
|
-
safeString = safeString.replace(/&/g, '--ampersand--')
|
|
18
|
-
safeString = safeString.replace(/\s/g, '_') // Replace spaces with underscores
|
|
19
|
-
|
|
20
|
-
return safeString
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function decodeIdentifier(identifier: string): Array<string> {
|
|
24
|
-
if (!identifier) {
|
|
25
|
-
return []
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let combinedString = identifier.replace(/--slash--/g, '/')
|
|
29
|
-
combinedString = combinedString.replace(/--backslash--/g, '\\')
|
|
30
|
-
combinedString = combinedString.replace(/--question--/g, '?')
|
|
31
|
-
combinedString = combinedString.replace(/--percent--/g, '%')
|
|
32
|
-
combinedString = combinedString.replace(/--hash--/g, '#')
|
|
33
|
-
combinedString = combinedString.replace(/--plus--/g, '+')
|
|
34
|
-
combinedString = combinedString.replace(/--equals--/g, '=')
|
|
35
|
-
combinedString = combinedString.replace(/--ampersand--/g, '&')
|
|
36
|
-
combinedString = combinedString.replace(/_/g, ' ') // Restore spaces
|
|
37
|
-
|
|
38
|
-
return combinedString.split('---')
|
|
39
|
-
}
|