UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

23 lines (22 loc) 1.17 kB
import FSExtra from "fs-extra"; import { writeFile } from "node:fs/promises"; import { dirname } from "node:path"; import micromatch from "micromatch"; import { globbedRoutesToRouteContext } from "../router/useViteRoutes.native.js"; import { globDir } from "../utils/globDir.native.js"; import { getTypedRoutesDeclarationFile } from "./getTypedRoutesDeclarationFile.native.js"; async function generateRouteTypes(outFile, routerRoot, ignoredRouteFiles) { var routePaths = globDir(routerRoot); ignoredRouteFiles && ignoredRouteFiles.length > 0 && (routePaths = micromatch.not(routePaths, ignoredRouteFiles, { // The path starts with './', such as './foo/bar/baz.test.tsx', and ignoredRouteFiles is like ['**/*.test.*'], so we need matchBase here. matchBase: !0 })); var routes = routePaths.reduce(function (acc, cur) { return acc[cur] = {}, acc; }, {}), context = globbedRoutesToRouteContext(routes, routerRoot), declarations = getTypedRoutesDeclarationFile(context); await FSExtra.ensureDir(dirname(outFile)), await writeFile(outFile, declarations); } export { generateRouteTypes }; //# sourceMappingURL=generateRouteTypes.native.js.map