@tanstack/router-plugin 1.121.20 → 1.121.21
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 +737 -0
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -0
- package/dist/cjs/core/code-splitter/compilers.d.cts +21 -0
- package/dist/cjs/core/code-splitter/framework-options.cjs +34 -0
- package/dist/cjs/core/code-splitter/framework-options.cjs.map +1 -0
- package/dist/cjs/core/code-splitter/framework-options.d.cts +10 -0
- package/dist/cjs/core/code-splitter/path-ids.cjs +37 -0
- package/dist/cjs/core/code-splitter/path-ids.cjs.map +1 -0
- package/dist/cjs/core/code-splitter/path-ids.d.cts +2 -0
- package/dist/cjs/core/config.cjs +46 -0
- package/dist/cjs/core/config.cjs.map +1 -0
- package/dist/cjs/core/config.d.cts +166 -0
- package/dist/cjs/core/constants.cjs +19 -0
- package/dist/cjs/core/constants.cjs.map +1 -0
- package/dist/cjs/core/constants.d.cts +5 -0
- package/dist/cjs/core/route-autoimport-plugin.cjs +104 -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 +180 -0
- package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -0
- package/dist/cjs/core/router-code-splitter-plugin.d.cts +3 -0
- package/dist/cjs/core/router-composed-plugin.cjs +33 -0
- package/dist/cjs/core/router-composed-plugin.cjs.map +1 -0
- package/dist/cjs/core/router-composed-plugin.d.cts +3 -0
- package/dist/cjs/core/router-generator-plugin.cjs +133 -0
- package/dist/cjs/core/router-generator-plugin.cjs.map +1 -0
- package/dist/cjs/core/router-generator-plugin.d.cts +3 -0
- package/dist/cjs/core/router-hmr-plugin.cjs +53 -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 +5 -0
- package/dist/cjs/core/utils.cjs.map +1 -0
- package/dist/cjs/core/utils.d.cts +1 -0
- package/dist/cjs/esbuild.cjs +22 -0
- package/dist/cjs/esbuild.cjs.map +1 -0
- package/dist/cjs/esbuild.d.cts +163 -0
- package/dist/cjs/index.cjs +10 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +4 -0
- package/dist/cjs/rspack.cjs +24 -0
- package/dist/cjs/rspack.cjs.map +1 -0
- package/dist/cjs/rspack.d.cts +175 -0
- package/dist/cjs/vite.cjs +25 -0
- package/dist/cjs/vite.cjs.map +1 -0
- package/dist/cjs/vite.d.cts +199 -0
- package/dist/cjs/webpack.cjs +24 -0
- package/dist/cjs/webpack.cjs.map +1 -0
- package/dist/cjs/webpack.d.cts +163 -0
- package/dist/esm/core/code-splitter/compilers.d.ts +21 -0
- package/dist/esm/core/code-splitter/compilers.js +719 -0
- package/dist/esm/core/code-splitter/compilers.js.map +1 -0
- package/dist/esm/core/code-splitter/framework-options.d.ts +10 -0
- package/dist/esm/core/code-splitter/framework-options.js +34 -0
- package/dist/esm/core/code-splitter/framework-options.js.map +1 -0
- package/dist/esm/core/code-splitter/path-ids.d.ts +2 -0
- package/dist/esm/core/code-splitter/path-ids.js +37 -0
- package/dist/esm/core/code-splitter/path-ids.js.map +1 -0
- package/dist/esm/core/config.d.ts +166 -0
- package/dist/esm/core/config.js +46 -0
- package/dist/esm/core/config.js.map +1 -0
- package/dist/esm/core/constants.d.ts +5 -0
- package/dist/esm/core/constants.js +19 -0
- package/dist/esm/core/constants.js.map +1 -0
- package/dist/esm/core/route-autoimport-plugin.d.ts +6 -0
- package/dist/esm/core/route-autoimport-plugin.js +87 -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.d.ts +3 -0
- package/dist/esm/core/router-code-splitter-plugin.js +180 -0
- package/dist/esm/core/router-code-splitter-plugin.js.map +1 -0
- package/dist/esm/core/router-composed-plugin.d.ts +3 -0
- package/dist/esm/core/router-composed-plugin.js +33 -0
- package/dist/esm/core/router-composed-plugin.js.map +1 -0
- package/dist/esm/core/router-generator-plugin.d.ts +3 -0
- package/dist/esm/core/router-generator-plugin.js +111 -0
- package/dist/esm/core/router-generator-plugin.js.map +1 -0
- package/dist/esm/core/router-hmr-plugin.d.ts +8 -0
- package/dist/esm/core/router-hmr-plugin.js +53 -0
- package/dist/esm/core/router-hmr-plugin.js.map +1 -0
- package/dist/esm/core/utils.d.ts +1 -0
- package/dist/esm/core/utils.js +5 -0
- package/dist/esm/core/utils.js.map +1 -0
- package/dist/esm/esbuild.d.ts +163 -0
- package/dist/esm/esbuild.js +22 -0
- package/dist/esm/esbuild.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/rspack.d.ts +175 -0
- package/dist/esm/rspack.js +24 -0
- package/dist/esm/rspack.js.map +1 -0
- package/dist/esm/vite.d.ts +199 -0
- package/dist/esm/vite.js +25 -0
- package/dist/esm/vite.js.map +1 -0
- package/dist/esm/webpack.d.ts +163 -0
- package/dist/esm/webpack.js +24 -0
- package/dist/esm/webpack.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
2
|
+
import { logDiff } from "@tanstack/router-utils";
|
|
3
|
+
import { getConfig, splitGroupingsSchema } from "./config.js";
|
|
4
|
+
import { detectCodeSplitGroupingsFromRoute, compileCodeSplitReferenceRoute, compileCodeSplitVirtualRoute } from "./code-splitter/compilers.js";
|
|
5
|
+
import { tsrSplit, splitRouteIdentNodes, defaultCodeSplitGroupings } from "./constants.js";
|
|
6
|
+
import { decodeIdentifier } from "./code-splitter/path-ids.js";
|
|
7
|
+
import { debug } from "./utils.js";
|
|
8
|
+
const bannedBeforeExternalPlugins = [
|
|
9
|
+
{
|
|
10
|
+
identifier: "@react-refresh",
|
|
11
|
+
pkg: "@vitejs/plugin-react",
|
|
12
|
+
usage: "viteReact()",
|
|
13
|
+
frameworks: ["vite"]
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
class FoundPluginInBeforeCode extends Error {
|
|
17
|
+
constructor(externalPlugin, pluginFramework) {
|
|
18
|
+
super(`We detected that the '${externalPlugin.pkg}' was passed before '@tanstack/router-plugin/${pluginFramework}'. Please make sure that '@tanstack/router-plugin' is passed before '${externalPlugin.pkg}' and try again:
|
|
19
|
+
e.g.
|
|
20
|
+
plugins: [
|
|
21
|
+
tanstackRouter(), // Place this before ${externalPlugin.usage}
|
|
22
|
+
${externalPlugin.usage},
|
|
23
|
+
]
|
|
24
|
+
`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const PLUGIN_NAME = "unplugin:router-code-splitter";
|
|
28
|
+
const unpluginRouterCodeSplitterFactory = (options = {}, { framework }) => {
|
|
29
|
+
let ROOT = process.cwd();
|
|
30
|
+
let userConfig = options;
|
|
31
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
32
|
+
const getGlobalCodeSplitGroupings = () => {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = userConfig.codeSplittingOptions) == null ? void 0 : _a.defaultBehavior) || defaultCodeSplitGroupings;
|
|
35
|
+
};
|
|
36
|
+
const getShouldSplitFn = () => {
|
|
37
|
+
var _a;
|
|
38
|
+
return (_a = userConfig.codeSplittingOptions) == null ? void 0 : _a.splitBehavior;
|
|
39
|
+
};
|
|
40
|
+
const handleCompilingReferenceFile = (code, id, generatorNodeInfo) => {
|
|
41
|
+
if (debug) console.info("Compiling Route: ", id);
|
|
42
|
+
const fromCode = detectCodeSplitGroupingsFromRoute({
|
|
43
|
+
code
|
|
44
|
+
});
|
|
45
|
+
if (fromCode.groupings) {
|
|
46
|
+
const res = splitGroupingsSchema.safeParse(fromCode.groupings);
|
|
47
|
+
if (!res.success) {
|
|
48
|
+
const message = res.error.errors.map((e) => e.message).join(". ");
|
|
49
|
+
throw new Error(
|
|
50
|
+
`The groupings for the route "${id}" are invalid.
|
|
51
|
+
${message}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const userShouldSplitFn = getShouldSplitFn();
|
|
56
|
+
const pluginSplitBehavior = userShouldSplitFn == null ? void 0 : userShouldSplitFn({
|
|
57
|
+
routeId: generatorNodeInfo.routePath
|
|
58
|
+
});
|
|
59
|
+
if (pluginSplitBehavior) {
|
|
60
|
+
const res = splitGroupingsSchema.safeParse(pluginSplitBehavior);
|
|
61
|
+
if (!res.success) {
|
|
62
|
+
const message = res.error.errors.map((e) => e.message).join(". ");
|
|
63
|
+
throw new Error(
|
|
64
|
+
`The groupings returned when using \`splitBehavior\` for the route "${id}" are invalid.
|
|
65
|
+
${message}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const splitGroupings = fromCode.groupings || pluginSplitBehavior || getGlobalCodeSplitGroupings();
|
|
70
|
+
const compiledReferenceRoute = compileCodeSplitReferenceRoute({
|
|
71
|
+
code,
|
|
72
|
+
runtimeEnv: isProduction ? "prod" : "dev",
|
|
73
|
+
codeSplitGroupings: splitGroupings,
|
|
74
|
+
targetFramework: userConfig.target,
|
|
75
|
+
filename: id,
|
|
76
|
+
id
|
|
77
|
+
});
|
|
78
|
+
if (debug) {
|
|
79
|
+
logDiff(code, compiledReferenceRoute.code);
|
|
80
|
+
console.log("Output:\n", compiledReferenceRoute.code + "\n\n");
|
|
81
|
+
}
|
|
82
|
+
return compiledReferenceRoute;
|
|
83
|
+
};
|
|
84
|
+
const handleCompilingVirtualFile = (code, id) => {
|
|
85
|
+
if (debug) console.info("Splitting Route: ", id);
|
|
86
|
+
const [_, ...pathnameParts] = id.split("?");
|
|
87
|
+
const searchParams = new URLSearchParams(pathnameParts.join("?"));
|
|
88
|
+
const splitValue = searchParams.get(tsrSplit);
|
|
89
|
+
if (!splitValue) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`The split value for the virtual route "${id}" was not found.`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const rawGrouping = decodeIdentifier(splitValue);
|
|
95
|
+
const grouping = [...new Set(rawGrouping)].filter(
|
|
96
|
+
(p) => splitRouteIdentNodes.includes(p)
|
|
97
|
+
);
|
|
98
|
+
const result = compileCodeSplitVirtualRoute({
|
|
99
|
+
code,
|
|
100
|
+
filename: id,
|
|
101
|
+
splitTargets: grouping
|
|
102
|
+
});
|
|
103
|
+
if (debug) {
|
|
104
|
+
logDiff(code, result.code);
|
|
105
|
+
console.log("Output:\n", result.code + "\n\n");
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
name: "tanstack-router:code-splitter:compile-reference-file",
|
|
112
|
+
enforce: "pre",
|
|
113
|
+
transform: {
|
|
114
|
+
filter: {
|
|
115
|
+
id: {
|
|
116
|
+
exclude: tsrSplit
|
|
117
|
+
},
|
|
118
|
+
code: "createFileRoute("
|
|
119
|
+
},
|
|
120
|
+
handler(code, id) {
|
|
121
|
+
var _a;
|
|
122
|
+
const generatorFileInfo = (_a = globalThis.TSR_ROUTES_BY_ID_MAP) == null ? void 0 : _a.get(id);
|
|
123
|
+
if (generatorFileInfo && code.includes("createFileRoute(")) {
|
|
124
|
+
for (const externalPlugin of bannedBeforeExternalPlugins) {
|
|
125
|
+
if (!externalPlugin.frameworks.includes(framework)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (code.includes(externalPlugin.identifier)) {
|
|
129
|
+
throw new FoundPluginInBeforeCode(externalPlugin, framework);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return handleCompilingReferenceFile(code, id, generatorFileInfo);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
vite: {
|
|
138
|
+
configResolved(config) {
|
|
139
|
+
ROOT = config.root;
|
|
140
|
+
userConfig = getConfig(options, ROOT);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
rspack() {
|
|
144
|
+
ROOT = process.cwd();
|
|
145
|
+
userConfig = getConfig(options, ROOT);
|
|
146
|
+
},
|
|
147
|
+
webpack(compiler) {
|
|
148
|
+
ROOT = process.cwd();
|
|
149
|
+
userConfig = getConfig(options, ROOT);
|
|
150
|
+
if (compiler.options.mode === "production") {
|
|
151
|
+
compiler.hooks.done.tap(PLUGIN_NAME, () => {
|
|
152
|
+
console.info("✅ " + PLUGIN_NAME + ": code-splitting done!");
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
process.exit(0);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "tanstack-router:code-splitter:compile-virtual-file",
|
|
162
|
+
enforce: "pre",
|
|
163
|
+
transform: {
|
|
164
|
+
filter: {
|
|
165
|
+
id: /tsr-split/
|
|
166
|
+
},
|
|
167
|
+
handler(code, id) {
|
|
168
|
+
const url = pathToFileURL(id);
|
|
169
|
+
url.searchParams.delete("v");
|
|
170
|
+
id = fileURLToPath(url).replace(/\\/g, "/");
|
|
171
|
+
return handleCompilingVirtualFile(code, id);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
};
|
|
177
|
+
export {
|
|
178
|
+
unpluginRouterCodeSplitterFactory
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=router-code-splitter-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-code-splitter-plugin.js","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 compileCodeSplitVirtualRoute,\n detectCodeSplitGroupingsFromRoute,\n} from './code-splitter/compilers'\nimport {\n defaultCodeSplitGroupings,\n splitRouteIdentNodes,\n tsrSplit,\n} from './constants'\nimport { decodeIdentifier } from './code-splitter/path-ids'\nimport { debug } from './utils'\nimport type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'\nimport type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type {\n UnpluginContextMeta,\n UnpluginFactory,\n TransformResult as UnpluginTransformResult,\n} from 'unplugin'\n\ntype BannedBeforeExternalPlugin = {\n identifier: string\n pkg: string\n usage: string\n frameworks: Array<UnpluginContextMeta['framework']>\n}\n\nconst bannedBeforeExternalPlugins: Array<BannedBeforeExternalPlugin> = [\n {\n identifier: '@react-refresh',\n pkg: '@vitejs/plugin-react',\n usage: 'viteReact()',\n frameworks: ['vite'],\n },\n]\n\nclass FoundPluginInBeforeCode extends Error {\n constructor(\n externalPlugin: BannedBeforeExternalPlugin,\n pluginFramework: string,\n ) {\n super(`We detected that the '${externalPlugin.pkg}' was passed before '@tanstack/router-plugin/${pluginFramework}'. Please make sure that '@tanstack/router-plugin' is passed before '${externalPlugin.pkg}' and try again: \ne.g.\nplugins: [\n tanstackRouter(), // Place this before ${externalPlugin.usage}\n ${externalPlugin.usage},\n]\n`)\n }\n}\n\nconst PLUGIN_NAME = 'unplugin:router-code-splitter'\n\nexport const unpluginRouterCodeSplitterFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}, { framework }) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n const isProduction = process.env.NODE_ENV === 'production'\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 })\n\n if (fromCode.groupings) {\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.routePath,\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 const compiledReferenceRoute = compileCodeSplitReferenceRoute({\n code,\n runtimeEnv: isProduction ? 'prod' : 'dev',\n codeSplitGroupings: splitGroupings,\n targetFramework: userConfig.target,\n filename: id,\n id,\n })\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 result = compileCodeSplitVirtualRoute({\n code,\n filename: id,\n splitTargets: grouping,\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,\n },\n code: 'createFileRoute(',\n },\n handler(code, id) {\n const generatorFileInfo = globalThis.TSR_ROUTES_BY_ID_MAP?.get(id)\n if (generatorFileInfo && code.includes('createFileRoute(')) {\n for (const externalPlugin of bannedBeforeExternalPlugins) {\n if (!externalPlugin.frameworks.includes(framework)) {\n continue\n }\n\n if (code.includes(externalPlugin.identifier)) {\n throw new FoundPluginInBeforeCode(externalPlugin, framework)\n }\n }\n\n return handleCompilingReferenceFile(code, id, generatorFileInfo)\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n userConfig = getConfig(options, ROOT)\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n userConfig = getConfig(options, ROOT)\n },\n\n webpack(compiler) {\n ROOT = process.cwd()\n userConfig = getConfig(options, ROOT)\n\n if (compiler.options.mode === 'production') {\n compiler.hooks.done.tap(PLUGIN_NAME, () => {\n console.info('✅ ' + PLUGIN_NAME + ': code-splitting done!')\n setTimeout(() => {\n process.exit(0)\n })\n })\n }\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 id = fileURLToP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,QAAA;AAAA,MACH;AAAA,IAEJ;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MAET,WAAW;AAAA,QACT,QAAQ;AAAA,UACN,IAAI;AAAA,QACN;AAAA,QACA,QAAQ,MAAM,IAAI;AACV,gBAAA,MAAM,cAAc,EAAE;AACxB,cAAA,aAAa,OAAO,GAAG;AAC3B,eAAK,cAAc,GAAG,EAAE,QAAQ,OAAO,GAAG;AACnC,iBAAA,2BAA2B,MAAM,EAAE;AAAA,QAAA;AAAA,MAC5C;AAAA,IACF;AAAA,EAEJ;AACF;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { unpluginRouterGeneratorFactory } from "./router-generator-plugin.js";
|
|
2
|
+
import { unpluginRouterCodeSplitterFactory } from "./router-code-splitter-plugin.js";
|
|
3
|
+
import { unpluginRouterHmrFactory } from "./router-hmr-plugin.js";
|
|
4
|
+
import { unpluginRouteAutoImportFactory } from "./route-autoimport-plugin.js";
|
|
5
|
+
const unpluginRouterComposedFactory = (options = {}, meta) => {
|
|
6
|
+
const getPlugin = (pluginFactory) => {
|
|
7
|
+
const plugin = pluginFactory(options, meta);
|
|
8
|
+
if (!Array.isArray(plugin)) {
|
|
9
|
+
return [plugin];
|
|
10
|
+
}
|
|
11
|
+
return plugin;
|
|
12
|
+
};
|
|
13
|
+
const routerGenerator = getPlugin(unpluginRouterGeneratorFactory);
|
|
14
|
+
const routerCodeSplitter = getPlugin(unpluginRouterCodeSplitterFactory);
|
|
15
|
+
const routeAutoImport = getPlugin(unpluginRouteAutoImportFactory);
|
|
16
|
+
const result = [...routerGenerator];
|
|
17
|
+
if (options.autoCodeSplitting) {
|
|
18
|
+
result.push(...routerCodeSplitter);
|
|
19
|
+
}
|
|
20
|
+
if (options.verboseFileRoutes === false) {
|
|
21
|
+
result.push(...routeAutoImport);
|
|
22
|
+
}
|
|
23
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
24
|
+
if (!isProduction && !options.autoCodeSplitting) {
|
|
25
|
+
const routerHmr = getPlugin(unpluginRouterHmrFactory);
|
|
26
|
+
result.push(...routerHmr);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
unpluginRouterComposedFactory
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=router-composed-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-composed-plugin.js","sources":["../../../src/core/router-composed-plugin.ts"],"sourcesContent":["import { unpluginRouterGeneratorFactory } from './router-generator-plugin'\nimport { unpluginRouterCodeSplitterFactory } from './router-code-splitter-plugin'\nimport { unpluginRouterHmrFactory } from './router-hmr-plugin'\nimport { unpluginRouteAutoImportFactory } from './route-autoimport-plugin'\nimport type { Config } from './config'\nimport type { UnpluginFactory } from 'unplugin'\n\nexport const unpluginRouterComposedFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}, meta) => {\n const getPlugin = (pluginFactory: UnpluginFactory<Partial<Config>>) => {\n const plugin = pluginFactory(options, meta)\n if (!Array.isArray(plugin)) {\n return [plugin]\n }\n return plugin\n }\n\n const routerGenerator = getPlugin(unpluginRouterGeneratorFactory)\n const routerCodeSplitter = getPlugin(unpluginRouterCodeSplitterFactory)\n const routeAutoImport = getPlugin(unpluginRouteAutoImportFactory)\n\n const result = [...routerGenerator]\n if (options.autoCodeSplitting) {\n result.push(...routerCodeSplitter)\n }\n if (options.verboseFileRoutes === false) {\n result.push(...routeAutoImport)\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n if (!isProduction && !options.autoCodeSplitting) {\n const routerHmr = getPlugin(unpluginRouterHmrFactory)\n result.push(...routerHmr)\n }\n return result\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,gCAET,CAAC,UAAU,IAAI,SAAS;AACpB,QAAA,YAAY,CAAC,kBAAoD;AAC/D,UAAA,SAAS,cAAc,SAAS,IAAI;AAC1C,QAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC1B,aAAO,CAAC,MAAM;AAAA,IAAA;AAET,WAAA;AAAA,EACT;AAEM,QAAA,kBAAkB,UAAU,8BAA8B;AAC1D,QAAA,qBAAqB,UAAU,iCAAiC;AAChE,QAAA,kBAAkB,UAAU,8BAA8B;AAE1D,QAAA,SAAS,CAAC,GAAG,eAAe;AAClC,MAAI,QAAQ,mBAAmB;AACtB,WAAA,KAAK,GAAG,kBAAkB;AAAA,EAAA;AAE/B,MAAA,QAAQ,sBAAsB,OAAO;AAChC,WAAA,KAAK,GAAG,eAAe;AAAA,EAAA;AAG1B,QAAA,eAAe,QAAQ,IAAI,aAAa;AAE9C,MAAI,CAAC,gBAAgB,CAAC,QAAQ,mBAAmB;AACzC,UAAA,YAAY,UAAU,wBAAwB;AAC7C,WAAA,KAAK,GAAG,SAAS;AAAA,EAAA;AAEnB,SAAA;AACT;"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { normalize, join, isAbsolute } from "node:path";
|
|
2
|
+
import { Generator, resolveConfigPath } from "@tanstack/router-generator";
|
|
3
|
+
import { getConfig } from "./config.js";
|
|
4
|
+
const PLUGIN_NAME = "unplugin:router-generator";
|
|
5
|
+
const unpluginRouterGeneratorFactory = (options = {}) => {
|
|
6
|
+
const ROOT = process.cwd();
|
|
7
|
+
let userConfig = options;
|
|
8
|
+
let generator;
|
|
9
|
+
const routeGenerationDisabled = () => userConfig.enableRouteGeneration === false;
|
|
10
|
+
const getRoutesDirectoryPath = () => {
|
|
11
|
+
return isAbsolute(userConfig.routesDirectory) ? userConfig.routesDirectory : join(ROOT, userConfig.routesDirectory);
|
|
12
|
+
};
|
|
13
|
+
const initConfigAndGenerator = () => {
|
|
14
|
+
userConfig = getConfig(options, ROOT);
|
|
15
|
+
generator = new Generator({
|
|
16
|
+
config: userConfig,
|
|
17
|
+
root: ROOT
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const generate = async (opts) => {
|
|
21
|
+
if (routeGenerationDisabled()) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let generatorEvent = void 0;
|
|
25
|
+
if (opts) {
|
|
26
|
+
const filePath = normalize(opts.file);
|
|
27
|
+
if (filePath === resolveConfigPath({ configDirectory: ROOT })) {
|
|
28
|
+
initConfigAndGenerator();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
generatorEvent = { path: filePath, type: opts.event };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await generator.run(generatorEvent);
|
|
35
|
+
globalThis.TSR_ROUTES_BY_ID_MAP = generator.getRoutesByFileMap();
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
name: "tanstack:router-generator",
|
|
42
|
+
enforce: "pre",
|
|
43
|
+
async watchChange(id, { event }) {
|
|
44
|
+
await generate({
|
|
45
|
+
file: id,
|
|
46
|
+
event
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
async buildStart() {
|
|
50
|
+
await generate();
|
|
51
|
+
},
|
|
52
|
+
vite: {
|
|
53
|
+
configResolved() {
|
|
54
|
+
initConfigAndGenerator();
|
|
55
|
+
},
|
|
56
|
+
async buildStart() {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
if (((_b = (_a = this.environment) == null ? void 0 : _a.config) == null ? void 0 : _b.consumer) === "server") {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await generate();
|
|
62
|
+
},
|
|
63
|
+
sharedDuringBuild: true
|
|
64
|
+
},
|
|
65
|
+
rspack(compiler) {
|
|
66
|
+
initConfigAndGenerator();
|
|
67
|
+
let handle = null;
|
|
68
|
+
compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate());
|
|
69
|
+
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
|
|
70
|
+
if (handle) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const routesDirectoryPath = getRoutesDirectoryPath();
|
|
74
|
+
const chokidar = await import("chokidar");
|
|
75
|
+
handle = chokidar.watch(routesDirectoryPath, { ignoreInitial: true }).on("add", (file) => generate({ file, event: "create" }));
|
|
76
|
+
await generate();
|
|
77
|
+
});
|
|
78
|
+
compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {
|
|
79
|
+
if (handle) {
|
|
80
|
+
await handle.close();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
webpack(compiler) {
|
|
85
|
+
initConfigAndGenerator();
|
|
86
|
+
let handle = null;
|
|
87
|
+
compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate());
|
|
88
|
+
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
|
|
89
|
+
if (handle) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const routesDirectoryPath = getRoutesDirectoryPath();
|
|
93
|
+
const chokidar = await import("chokidar");
|
|
94
|
+
handle = chokidar.watch(routesDirectoryPath, { ignoreInitial: true }).on("add", (file) => generate({ file, event: "create" }));
|
|
95
|
+
await generate();
|
|
96
|
+
});
|
|
97
|
+
compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {
|
|
98
|
+
if (handle) {
|
|
99
|
+
await handle.close();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
compiler.hooks.done.tap(PLUGIN_NAME, () => {
|
|
103
|
+
console.info("✅ " + PLUGIN_NAME + ": route-tree generation done");
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
unpluginRouterGeneratorFactory
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=router-generator-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-generator-plugin.js","sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\nimport { getConfig } from './config'\n\nimport type { GeneratorEvent } from '@tanstack/router-generator'\nimport type { FSWatcher } from 'chokidar'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n const ROOT: string = process.cwd()\n let userConfig = options as Config\n let generator: Generator\n\n const routeGenerationDisabled = () =>\n userConfig.enableRouteGeneration === false\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const initConfigAndGenerator = () => {\n userConfig = getConfig(options, ROOT)\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async (opts?: {\n file: string\n event: 'create' | 'update' | 'delete'\n }) => {\n if (routeGenerationDisabled()) {\n return\n }\n let generatorEvent: GeneratorEvent | undefined = undefined\n if (opts) {\n const filePath = normalize(opts.file)\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n generatorEvent = { path: filePath, type: opts.event }\n }\n\n try {\n await generator.run(generatorEvent)\n globalThis.TSR_ROUTES_BY_ID_MAP = generator.getRoutesByFileMap()\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'tanstack:router-generator',\n enforce: 'pre',\n async watchChange(id, { event }) {\n await generate({\n file: id,\n event,\n })\n },\n async buildStart() {\n await generate()\n },\n vite: {\n configResolved() {\n initConfigAndGenerator()\n },\n async buildStart() {\n // to support vite 5, we need to optionally chain the access to the environment\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (this.environment?.config?.consumer === 'server') {\n // When building in environment mode, we only need to generate routes\n // for the client environment\n return\n }\n await generate()\n },\n sharedDuringBuild: true,\n },\n rspack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // rspack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n },\n webpack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // webpack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n\n compiler.hooks.done.tap(PLUGIN_NAME, () => {\n console.info('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n })\n },\n }\n}\n"],"names":[],"mappings":";;;AASA,MAAM,cAAc;AAEb,MAAM,iCAET,CAAC,UAAU,OAAO;AACd,QAAA,OAAe,QAAQ,IAAI;AACjC,MAAI,aAAa;AACb,MAAA;AAEE,QAAA,0BAA0B,MAC9B,WAAW,0BAA0B;AACvC,QAAM,yBAAyB,MAAM;AAC5B,WAAA,WAAW,WAAW,eAAe,IACxC,WAAW,kBACX,KAAK,MAAM,WAAW,eAAe;AAAA,EAC3C;AAEA,QAAM,yBAAyB,MAAM;AACtB,iBAAA,UAAU,SAAS,IAAI;AACpC,gBAAY,IAAI,UAAU;AAAA,MACxB,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA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CAAC,SAAS,SAAS,EAAE,MAAM,OAAO,SAAA,CAAU,CAAC;AAE1D,cAAM,SAAS;AAAA,MAAA,CAChB;AAED,eAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,YAAI,QAAQ;AACV,gBAAM,OAAO,MAAM;AAAA,QAAA;AAAA,MACrB,CACD;AAAA,IACH;AAAA,IACA,QAAQ,UAAU;AACO,6BAAA;AAEvB,UAAI,SAA2B;AAE/B,eAAS,MAAM,UAAU,WAAW,aAAa,MAAM,UAAU;AAEjE,eAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,YAAI,QAAQ;AACV;AAAA,QAAA;AAIF,cAAM,sBAAsB,uBAAuB;AAC7C,cAAA,WAAW,MAAM,OAAO,UAAU;AACxC,iBAAS,SACN,MAAM,qBAAqB,EAAE,eAAe,KAAA,CAAM,EAClD,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,MAAM,OAAO,SAAA,CAAU,CAAC;AAE1D,cAAM,SAAS;AAAA,MAAA,CAChB;AAED,eAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,YAAI,QAAQ;AACV,gBAAM,OAAO,MAAM;AAAA,QAAA;AAAA,MACrB,CACD;AAED,eAAS,MAAM,KAAK,IAAI,aAAa,MAAM;AACjC,gBAAA,KAAK,OAAO,cAAc,8BAA8B;AAAA,MAAA,CACjE;AAAA,IAAA;AAAA,EAEL;AACF;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
import { UnpluginFactory } from 'unplugin';
|
|
3
|
+
/**
|
|
4
|
+
* This plugin adds HMR support for file routes.
|
|
5
|
+
* It is only added to the composed plugin in dev when autoCodeSplitting is disabled, since the code splitting plugin
|
|
6
|
+
* handles HMR for code-split routes itself.
|
|
7
|
+
*/
|
|
8
|
+
export declare const unpluginRouterHmrFactory: UnpluginFactory<Partial<Config> | undefined>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseAst, generateFromAst, logDiff } from "@tanstack/router-utils";
|
|
2
|
+
import { getConfig } from "./config.js";
|
|
3
|
+
import { routeHmrStatement } from "./route-hmr-statement.js";
|
|
4
|
+
import { debug } from "./utils.js";
|
|
5
|
+
const unpluginRouterHmrFactory = (options = {}) => {
|
|
6
|
+
let ROOT = process.cwd();
|
|
7
|
+
return {
|
|
8
|
+
name: "tanstack-router:hmr",
|
|
9
|
+
enforce: "pre",
|
|
10
|
+
transform: {
|
|
11
|
+
filter: {
|
|
12
|
+
code: "createFileRoute("
|
|
13
|
+
},
|
|
14
|
+
handler(code, id) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!((_a = globalThis.TSR_ROUTES_BY_ID_MAP) == null ? void 0 : _a.has(id))) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (debug) console.info("Adding HMR handling to route ", id);
|
|
20
|
+
const ast = parseAst({ code });
|
|
21
|
+
ast.program.body.push(routeHmrStatement);
|
|
22
|
+
const result = generateFromAst(ast, {
|
|
23
|
+
sourceMaps: true,
|
|
24
|
+
filename: id,
|
|
25
|
+
sourceFileName: id
|
|
26
|
+
});
|
|
27
|
+
if (debug) {
|
|
28
|
+
logDiff(code, result.code);
|
|
29
|
+
console.log("Output:\n", result.code + "\n\n");
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
vite: {
|
|
35
|
+
configResolved(config) {
|
|
36
|
+
ROOT = config.root;
|
|
37
|
+
getConfig(options, ROOT);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
rspack() {
|
|
41
|
+
ROOT = process.cwd();
|
|
42
|
+
getConfig(options, ROOT);
|
|
43
|
+
},
|
|
44
|
+
webpack() {
|
|
45
|
+
ROOT = process.cwd();
|
|
46
|
+
getConfig(options, ROOT);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
unpluginRouterHmrFactory
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=router-hmr-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-hmr-plugin.js","sources":["../../../src/core/router-hmr-plugin.ts"],"sourcesContent":["import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport { getConfig } from './config'\nimport { routeHmrStatement } from './route-hmr-statement'\nimport { debug } from './utils'\nimport type { Config } from './config'\nimport type { UnpluginFactory } from 'unplugin'\n\n/**\n * This plugin adds HMR support for file routes.\n * It is only added to the composed plugin in dev when autoCodeSplitting is disabled, since the code splitting plugin\n * handles HMR for code-split routes itself.\n */\nexport const unpluginRouterHmrFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n return {\n name: 'tanstack-router:hmr',\n enforce: 'pre',\n\n transform: {\n filter: {\n code: 'createFileRoute(',\n },\n handler(code, id) {\n if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(id)) {\n return null\n }\n\n if (debug) console.info('Adding HMR handling to route ', id)\n\n const ast = parseAst({ code })\n ast.program.body.push(routeHmrStatement)\n const result = generateFromAst(ast, {\n sourceMaps: true,\n filename: id,\n sourceFileName: id,\n })\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n return result\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n userConfig = getConfig(options, ROOT)\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n userConfig = getConfig(options, ROOT)\n },\n\n webpack() {\n ROOT = process.cwd()\n userConfig = getConfig(options, ROOT)\n },\n }\n}\n"],"names":[],"mappings":";;;;AAYO,MAAM,2BAET,CAAC,UAAU,OAAO;AAChB,MAAA,OAAe,QAAQ,IAAI;AAGxB,SAAA;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,WAAW;AAAA,MACT,QAAQ;AAAA,QACN,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,MAAM,IAAI;;AAChB,YAAI,GAAC,gBAAW,yBAAX,mBAAiC,IAAI,MAAK;AACtC,iBAAA;AAAA,QAAA;AAGT,YAAI,MAAO,SAAQ,KAAK,iCAAiC,EAAE;AAE3D,cAAM,MAAM,SAAS,EAAE,MAAM;AACzB,YAAA,QAAQ,KAAK,KAAK,iBAAiB;AACjC,cAAA,SAAS,gBAAgB,KAAK;AAAA,UAClC,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,gBAAgB;AAAA,QAAA,CACjB;AACD,YAAI,OAAO;AACD,kBAAA,MAAM,OAAO,IAAI;AACzB,kBAAQ,IAAI,aAAa,OAAO,OAAO,MAAM;AAAA,QAAA;AAExC,eAAA;AAAA,MAAA;AAAA,IAEX;AAAA,IAEA,MAAM;AAAA,MACJ,eAAe,QAAQ;AACrB,eAAO,OAAO;AACD,kBAAU,SAAS,IAAI;AAAA,MAAA;AAAA,IAExC;AAAA,IAEA,SAAS;AACP,aAAO,QAAQ,IAAI;AACN,gBAAU,SAAS,IAAI;AAAA,IACtC;AAAA,IAEA,UAAU;AACR,aAAO,QAAQ,IAAI;AACN,gBAAU,SAAS,IAAI;AAAA,IAAA;AAAA,EAExC;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debug: boolean | "" | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/core/utils.ts"],"sourcesContent":["export const debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG)\n"],"names":[],"mappings":"AAAa,MAAA,QACX,QAAQ,IAAI,kBACZ,CAAC,QAAQ,eAAe,EAAE,SAAS,QAAQ,IAAI,cAAc;"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { configSchema, Config } from './core/config.js';
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* ```ts
|
|
5
|
+
* export default {
|
|
6
|
+
* plugins: [TanStackRouterGeneratorEsbuild()],
|
|
7
|
+
* // ...
|
|
8
|
+
* }
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
declare const TanStackRouterGeneratorEsbuild: (options?: Partial<{
|
|
12
|
+
target: "react" | "solid";
|
|
13
|
+
routeFileIgnorePrefix: string;
|
|
14
|
+
routesDirectory: string;
|
|
15
|
+
quoteStyle: "single" | "double";
|
|
16
|
+
semicolons: boolean;
|
|
17
|
+
disableLogging: boolean;
|
|
18
|
+
routeTreeFileHeader: string[];
|
|
19
|
+
indexToken: string;
|
|
20
|
+
routeToken: string;
|
|
21
|
+
generatedRouteTree: string;
|
|
22
|
+
disableTypes: boolean;
|
|
23
|
+
addExtensions: boolean;
|
|
24
|
+
enableRouteTreeFormatting: boolean;
|
|
25
|
+
routeTreeFileFooter: string[];
|
|
26
|
+
tmpDir: string;
|
|
27
|
+
enableRouteGeneration?: boolean | undefined;
|
|
28
|
+
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
29
|
+
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
30
|
+
routeFilePrefix?: string | undefined;
|
|
31
|
+
routeFileIgnorePattern?: string | undefined;
|
|
32
|
+
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
33
|
+
verboseFileRoutes?: boolean | undefined;
|
|
34
|
+
autoCodeSplitting?: boolean | undefined;
|
|
35
|
+
customScaffolding?: {
|
|
36
|
+
routeTemplate?: string | undefined;
|
|
37
|
+
lazyRouteTemplate?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
experimental?: {
|
|
40
|
+
enableCodeSplitting?: boolean | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
43
|
+
}> | undefined) => import('unplugin').EsbuildPlugin;
|
|
44
|
+
/**
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* export default {
|
|
48
|
+
* plugins: [TanStackRouterCodeSplitterEsbuild()],
|
|
49
|
+
* // ...
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare const TanStackRouterCodeSplitterEsbuild: (options?: Partial<{
|
|
54
|
+
target: "react" | "solid";
|
|
55
|
+
routeFileIgnorePrefix: string;
|
|
56
|
+
routesDirectory: string;
|
|
57
|
+
quoteStyle: "single" | "double";
|
|
58
|
+
semicolons: boolean;
|
|
59
|
+
disableLogging: boolean;
|
|
60
|
+
routeTreeFileHeader: string[];
|
|
61
|
+
indexToken: string;
|
|
62
|
+
routeToken: string;
|
|
63
|
+
generatedRouteTree: string;
|
|
64
|
+
disableTypes: boolean;
|
|
65
|
+
addExtensions: boolean;
|
|
66
|
+
enableRouteTreeFormatting: boolean;
|
|
67
|
+
routeTreeFileFooter: string[];
|
|
68
|
+
tmpDir: string;
|
|
69
|
+
enableRouteGeneration?: boolean | undefined;
|
|
70
|
+
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
71
|
+
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
72
|
+
routeFilePrefix?: string | undefined;
|
|
73
|
+
routeFileIgnorePattern?: string | undefined;
|
|
74
|
+
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
75
|
+
verboseFileRoutes?: boolean | undefined;
|
|
76
|
+
autoCodeSplitting?: boolean | undefined;
|
|
77
|
+
customScaffolding?: {
|
|
78
|
+
routeTemplate?: string | undefined;
|
|
79
|
+
lazyRouteTemplate?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
experimental?: {
|
|
82
|
+
enableCodeSplitting?: boolean | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
85
|
+
}> | undefined) => import('unplugin').EsbuildPlugin;
|
|
86
|
+
/**
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* export default {
|
|
90
|
+
* plugins: [tanstackRouter()],
|
|
91
|
+
* // ...
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare const TanStackRouterEsbuild: (options?: Partial<{
|
|
96
|
+
target: "react" | "solid";
|
|
97
|
+
routeFileIgnorePrefix: string;
|
|
98
|
+
routesDirectory: string;
|
|
99
|
+
quoteStyle: "single" | "double";
|
|
100
|
+
semicolons: boolean;
|
|
101
|
+
disableLogging: boolean;
|
|
102
|
+
routeTreeFileHeader: string[];
|
|
103
|
+
indexToken: string;
|
|
104
|
+
routeToken: string;
|
|
105
|
+
generatedRouteTree: string;
|
|
106
|
+
disableTypes: boolean;
|
|
107
|
+
addExtensions: boolean;
|
|
108
|
+
enableRouteTreeFormatting: boolean;
|
|
109
|
+
routeTreeFileFooter: string[];
|
|
110
|
+
tmpDir: string;
|
|
111
|
+
enableRouteGeneration?: boolean | undefined;
|
|
112
|
+
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
113
|
+
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
114
|
+
routeFilePrefix?: string | undefined;
|
|
115
|
+
routeFileIgnorePattern?: string | undefined;
|
|
116
|
+
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
117
|
+
verboseFileRoutes?: boolean | undefined;
|
|
118
|
+
autoCodeSplitting?: boolean | undefined;
|
|
119
|
+
customScaffolding?: {
|
|
120
|
+
routeTemplate?: string | undefined;
|
|
121
|
+
lazyRouteTemplate?: string | undefined;
|
|
122
|
+
} | undefined;
|
|
123
|
+
experimental?: {
|
|
124
|
+
enableCodeSplitting?: boolean | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
127
|
+
}> | undefined) => import('unplugin').EsbuildPlugin;
|
|
128
|
+
declare const tanstackRouter: (options?: Partial<{
|
|
129
|
+
target: "react" | "solid";
|
|
130
|
+
routeFileIgnorePrefix: string;
|
|
131
|
+
routesDirectory: string;
|
|
132
|
+
quoteStyle: "single" | "double";
|
|
133
|
+
semicolons: boolean;
|
|
134
|
+
disableLogging: boolean;
|
|
135
|
+
routeTreeFileHeader: string[];
|
|
136
|
+
indexToken: string;
|
|
137
|
+
routeToken: string;
|
|
138
|
+
generatedRouteTree: string;
|
|
139
|
+
disableTypes: boolean;
|
|
140
|
+
addExtensions: boolean;
|
|
141
|
+
enableRouteTreeFormatting: boolean;
|
|
142
|
+
routeTreeFileFooter: string[];
|
|
143
|
+
tmpDir: string;
|
|
144
|
+
enableRouteGeneration?: boolean | undefined;
|
|
145
|
+
codeSplittingOptions?: import('./core/config.js').CodeSplittingOptions | undefined;
|
|
146
|
+
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
147
|
+
routeFilePrefix?: string | undefined;
|
|
148
|
+
routeFileIgnorePattern?: string | undefined;
|
|
149
|
+
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
150
|
+
verboseFileRoutes?: boolean | undefined;
|
|
151
|
+
autoCodeSplitting?: boolean | undefined;
|
|
152
|
+
customScaffolding?: {
|
|
153
|
+
routeTemplate?: string | undefined;
|
|
154
|
+
lazyRouteTemplate?: string | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
experimental?: {
|
|
157
|
+
enableCodeSplitting?: boolean | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
160
|
+
}> | undefined) => import('unplugin').EsbuildPlugin;
|
|
161
|
+
export default TanStackRouterEsbuild;
|
|
162
|
+
export { configSchema, TanStackRouterGeneratorEsbuild, TanStackRouterCodeSplitterEsbuild, TanStackRouterEsbuild, tanstackRouter, };
|
|
163
|
+
export type { Config };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createEsbuildPlugin } from "unplugin";
|
|
2
|
+
import { configSchema } from "./core/config.js";
|
|
3
|
+
import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
|
|
4
|
+
import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
|
|
5
|
+
import { unpluginRouterComposedFactory } from "./core/router-composed-plugin.js";
|
|
6
|
+
const TanStackRouterGeneratorEsbuild = createEsbuildPlugin(
|
|
7
|
+
unpluginRouterGeneratorFactory
|
|
8
|
+
);
|
|
9
|
+
const TanStackRouterCodeSplitterEsbuild = createEsbuildPlugin(
|
|
10
|
+
unpluginRouterCodeSplitterFactory
|
|
11
|
+
);
|
|
12
|
+
const TanStackRouterEsbuild = createEsbuildPlugin(unpluginRouterComposedFactory);
|
|
13
|
+
const tanstackRouter = TanStackRouterEsbuild;
|
|
14
|
+
export {
|
|
15
|
+
TanStackRouterCodeSplitterEsbuild,
|
|
16
|
+
TanStackRouterEsbuild,
|
|
17
|
+
TanStackRouterGeneratorEsbuild,
|
|
18
|
+
configSchema,
|
|
19
|
+
TanStackRouterEsbuild as default,
|
|
20
|
+
tanstackRouter
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=esbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.js","sources":["../../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } 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 {\n * plugins: [TanStackRouterGeneratorEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterGeneratorEsbuild = createEsbuildPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterCodeSplitterEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterEsbuild = createEsbuildPlugin(\n unpluginRouterCodeSplitterFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [tanstackRouter()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterEsbuild = createEsbuildPlugin(unpluginRouterComposedFactory)\nconst tanstackRouter = TanStackRouterEsbuild\nexport default TanStackRouterEsbuild\n\nexport {\n configSchema,\n TanStackRouterGeneratorEsbuild,\n TanStackRouterCodeSplitterEsbuild,\n TanStackRouterEsbuild,\n tanstackRouter,\n}\n\nexport type { Config }\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,iCAAiC;AAAA,EACrC;AACF;AAWA,MAAM,oCAAoC;AAAA,EACxC;AACF;AAWM,MAAA,wBAAwB,oBAAoB,6BAA6B;AAC/E,MAAM,iBAAiB;"}
|