UNPKG

one

Version:

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

17 lines (16 loc) 670 B
const routeIdReturnRegex = /return\s*"\.\/[^"]+"/; function replaceLoader({ code, loaderData }) { const stringifiedData = JSON.stringify(loaderData), safeData = stringifiedData.replace(/\$/g, "$$$$"); return code.includes("__vxrn__loader__") ? code.replace(/["']__vxrn__loader__['"]/, // make sure this ' ' is added in front, // minifiers will do `return"something" // but if its null then it becomes returnnull " " + safeData) : routeIdReturnRegex.test(code) ? code.replace(routeIdReturnRegex, "return " + safeData) : code + ` export const loader = () => (${stringifiedData})`; } export { replaceLoader }; //# sourceMappingURL=replaceLoader.mjs.map