UNPKG

one

Version:

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

21 lines (20 loc) 770 B
var routeIdReturnRegex = /return\s*"\.\/[^"]+"/; function replaceLoader(param) { var { code, loaderData } = param, stringifiedData = JSON.stringify(loaderData), safeData = stringifiedData.replace(/\$/g, "$$$$"), out = function () { 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})`; }(); return out; } export { replaceLoader }; //# sourceMappingURL=replaceLoader.native.js.map