UNPKG

@tanstack/router-plugin

Version:

Modern and scalable routing for React applications

47 lines (46 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const zod = require("zod"); const routerGenerator = require("@tanstack/router-generator"); const splitGroupingsSchema = zod.z.array( zod.z.array( zod.z.union([ zod.z.literal("loader"), zod.z.literal("component"), zod.z.literal("pendingComponent"), zod.z.literal("errorComponent"), zod.z.literal("notFoundComponent") ]) ), { message: " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]" } ).superRefine((val, ctx) => { const flattened = val.flat(); const unique = [...new Set(flattened)]; if (unique.length !== flattened.length) { ctx.addIssue({ code: "custom", message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]. You input was: ${JSON.stringify(val)}.` }); } }); const codeSplittingOptionsSchema = zod.z.object({ splitBehavior: zod.z.function().optional(), defaultBehavior: splitGroupingsSchema.optional() }); const configSchema = routerGenerator.configSchema.extend({ enableRouteGeneration: zod.z.boolean().optional(), codeSplittingOptions: zod.z.custom((v) => { return codeSplittingOptionsSchema.parse(v); }).optional() }); const getConfig = (inlineConfig, root) => { const config = routerGenerator.getConfig(inlineConfig, root); return configSchema.parse({ ...config, ...inlineConfig }); }; exports.configSchema = configSchema; exports.getConfig = getConfig; exports.splitGroupingsSchema = splitGroupingsSchema; //# sourceMappingURL=config.cjs.map