@tanstack/router-plugin
Version:
Modern and scalable routing for React applications
26 lines (25 loc) • 929 B
JavaScript
import * as t from "@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 t.identifier(name);
}
//#endregion
export { debug, getUniqueProgramIdentifier, normalizePath };
//# sourceMappingURL=utils.js.map