UNPKG

@tanstack/router-plugin

Version:

Modern and scalable routing for React applications

30 lines (29 loc) 1.14 kB
const require_runtime = require("../_virtual/_rolldown/runtime.cjs"); let _babel_types = require("@babel/types"); _babel_types = require_runtime.__toESM(_babel_types); //#region src/core/utils.ts var debug = process.env.TSR_VITE_DEBUG && ["true", "router-plugin"].includes(process.env.TSR_VITE_DEBUG); /** * Normalizes a file path by converting Windows backslashes to forward slashes. * This ensures consistent path handling across different bundlers and operating systems. * * The route generator stores paths with forward slashes, but rspack/webpack on Windows * pass native paths with backslashes to transform handlers. */ function normalizePath(path) { return path.replace(/\\/g, "/"); } function getUniqueProgramIdentifier(programPath, baseName) { let name = baseName; let suffix = 2; while (programPath.scope.hasBinding(name) || programPath.scope.hasGlobal(name)) { name = `${baseName}${suffix}`; suffix++; } return _babel_types.identifier(name); } //#endregion exports.debug = debug; exports.getUniqueProgramIdentifier = getUniqueProgramIdentifier; exports.normalizePath = normalizePath; //# sourceMappingURL=utils.cjs.map