UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 23.5 kB
{"version":3,"file":"buildPage.js","names":[],"sources":["esm/cli/buildPage.js"],"sourcesContent":["import { join } from \"node:path\";\nimport FSExtra from \"fs-extra\";\nimport { normalizePath } from \"vite\";\nimport * as constants from \"../constants\";\nimport { LOADER_JS_POSTFIX_UNCACHED } from \"../constants\";\nimport {\n encodeReservedFilenameChars,\n getLoaderPath,\n getPreloadCSSPath,\n getPreloadPath\n} from \"../utils/cleanUrl\";\nimport { isResponse } from \"../utils/isResponse\";\nimport { toAbsolute, toAbsoluteUrl } from \"../utils/toAbsolute\";\nimport { getRouteExports } from \"./serverRouteModules\";\nconst { outputFile } = FSExtra;\nfunction urlPathToFilePath(urlPath) {\n const parts = urlPath.replace(/^\\//, \"\").split(\"/\");\n return join(...parts);\n}\nconst buildTiming = process.env.ONE_BUILD_TIMING === \"1\";\nconst timings = {};\nfunction recordTiming(label, ms) {\n if (!buildTiming) return;\n (timings[label] ||= []).push(ms);\n}\nfunction printBuildTimings() {\n if (!buildTiming) return;\n console.info(\"\\n\\u{1F4CA} Build timing breakdown:\");\n for (const [label, times] of Object.entries(timings)) {\n const total = times.reduce((a, b) => a + b, 0);\n const avg = total / times.length;\n console.info(\n ` ${label}: ${avg.toFixed(1)}ms avg, ${total.toFixed(0)}ms total (${times.length} calls)`\n );\n }\n}\nasync function buildPage(serverEntry, routerRoot, path, relativeId, params, foundRoute, clientManifestEntry, staticDir, clientDir, builtMiddlewares, serverJsPath, preloads, allCSS, layoutCSS, routePreloads, allCSSContents, criticalPreloads, deferredPreloads, useAfterLCP, useAfterLCPAggressive) {\n let t0 = performance.now();\n const render = await getRender(serverEntry);\n recordTiming(\"getRender\", performance.now() - t0);\n const htmlPath = encodeReservedFilenameChars(\n `${path.endsWith(\"/\") ? `${removeTrailingSlash(path)}/index` : path}.html`\n );\n const clientJsPath = clientManifestEntry ? normalizePath(join(clientDir, clientManifestEntry.file)) : \"\";\n const htmlOutPath = toAbsolute(join(staticDir, htmlPath));\n const preloadPath = getPreloadPath(path);\n const cssPreloadPath = getPreloadCSSPath(path);\n let loaderPath = \"\";\n let loaderData = {};\n try {\n const routeImports = [];\n const routeRegistrations = [];\n let routeIndex = 0;\n for (const [routeKey, bundlePath] of Object.entries(routePreloads)) {\n const varName = `_r${routeIndex++}`;\n routeImports.push(`import * as ${varName} from \"${bundlePath}\"`);\n routeRegistrations.push(`registerPreloadedRoute(\"${routeKey}\", ${varName})`);\n }\n const registrationCalls = routeRegistrations.map(\n (call) => call.replace(\"registerPreloadedRoute(\", \"window.__oneRegisterPreloadedRoute(\")\n );\n const preloadContent = [\n // import all route modules\n ...routeImports,\n // static imports for cache warming (original behavior)\n ...preloads.map((preload) => `import \"${preload}\"`),\n // register all route modules using window global\n ...registrationCalls\n ].join(\"\\n\");\n t0 = performance.now();\n await FSExtra.writeFile(\n join(clientDir, urlPathToFilePath(preloadPath)),\n preloadContent\n );\n recordTiming(\"writePreload\", performance.now() - t0);\n const uniqueCSS = [...new Set(allCSS)];\n const cssPreloadContent = `\nconst CSS_TIMEOUT = 1000\nconst cssUrls = ${JSON.stringify(uniqueCSS)}\n\n// Global cache for loaded CSS - avoids DOM queries and tracks across navigations\nconst loaded = (window.__oneLoadedCSS ||= new Set())\n\n// Prefetch CSS without applying - called on link hover\nexport function prefetchCSS() {\n cssUrls.forEach(href => {\n if (loaded.has(href)) return\n if (document.querySelector(\\`link[href=\"\\${href}\"]\\`)) return\n const link = document.createElement('link')\n link.rel = 'prefetch'\n link.as = 'style'\n link.href = href\n document.head.appendChild(link)\n })\n}\n\n// Inject CSS to apply styles - called on actual navigation\nexport function injectCSS() {\n return Promise.all(cssUrls.map(href => {\n // Skip if already loaded\n if (loaded.has(href)) return Promise.resolve()\n // Remove any prefetch link for this href\n const prefetchLink = document.querySelector(\\`link[rel=\"prefetch\"][href=\"\\${href}\"]\\`)\n if (prefetchLink) prefetchLink.remove()\n // Skip if stylesheet already exists in DOM\n if (document.querySelector(\\`link[rel=\"stylesheet\"][href=\"\\${href}\"]\\`)) {\n loaded.add(href)\n return Promise.resolve()\n }\n return new Promise(resolve => {\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = href\n const timeoutId = setTimeout(() => {\n console.warn('[one] CSS load timeout:', href)\n loaded.add(href)\n resolve()\n }, CSS_TIMEOUT)\n link.onload = link.onerror = () => {\n clearTimeout(timeoutId)\n loaded.add(href)\n resolve()\n }\n document.head.appendChild(link)\n })\n }))\n}\n\n// For backwards compatibility, also prefetch on import\nprefetchCSS()\n`;\n t0 = performance.now();\n await FSExtra.writeFile(\n join(clientDir, urlPathToFilePath(cssPreloadPath)),\n cssPreloadContent\n );\n recordTiming(\"writeCSSPreload\", performance.now() - t0);\n t0 = performance.now();\n const exported = await getRouteExports(serverEntry, routerRoot, foundRoute.file);\n recordTiming(\"importServerModule\", performance.now() - t0);\n const loaderProps = { path, params };\n const matches = [];\n t0 = performance.now();\n if (foundRoute.layouts?.length) {\n const layoutResults = await Promise.all(\n foundRoute.layouts.map(async (layout) => {\n try {\n if (!layout.loaderServerPath) {\n return { contextKey: layout.contextKey, loaderData: void 0 };\n }\n const layoutExported = await getRouteExports(\n serverEntry,\n routerRoot,\n layout.contextKey\n );\n const layoutLoaderData = await layoutExported?.loader?.(loaderProps);\n return { contextKey: layout.contextKey, loaderData: layoutLoaderData };\n } catch (err) {\n if (isResponse(err)) {\n throw err;\n }\n console.warn(\n `[one] Warning: layout loader failed for ${layout.contextKey}:`,\n err\n );\n return { contextKey: layout.contextKey, loaderData: void 0 };\n }\n })\n );\n for (const result of layoutResults) {\n matches.push({\n routeId: result.contextKey,\n pathname: path,\n params: params || {},\n loaderData: result.loaderData\n });\n }\n }\n recordTiming(\"layoutLoaders\", performance.now() - t0);\n t0 = performance.now();\n let loaderRedirectInfo = null;\n if (exported.loader && foundRoute.type !== \"ssr\") {\n try {\n loaderData = await exported.loader?.(loaderProps) ?? null;\n } catch (err) {\n if (isResponse(err)) {\n loaderRedirectInfo = extractRedirectInfo(err);\n } else {\n throw err;\n }\n }\n if (!loaderRedirectInfo && loaderData && (isResponse(loaderData) || loaderData instanceof Response || loaderData?.constructor?.name === \"Response\")) {\n loaderRedirectInfo = extractRedirectInfo(loaderData);\n loaderData = {};\n }\n if (clientJsPath) {\n const loaderPartialPath = join(clientDir, urlPathToFilePath(getLoaderPath(path)));\n const uncachedNativePath = loaderPartialPath.replace(constants.LOADER_JS_POSTFIX, LOADER_JS_POSTFIX_UNCACHED).replace(/\\.js$/, \".native.js\");\n if (loaderRedirectInfo) {\n const redirectData = JSON.stringify({\n __oneRedirect: loaderRedirectInfo.path,\n __oneRedirectStatus: loaderRedirectInfo.status\n });\n await outputFile(\n loaderPartialPath,\n `export function loader(){return ${redirectData}}`\n );\n const nativeCjs = `exports.loader = function(){return ${redirectData}}`;\n await outputFile(loaderPartialPath.replace(/\\.js$/, \".native.js\"), nativeCjs);\n await outputFile(uncachedNativePath, nativeCjs);\n loaderPath = getLoaderPath(path);\n loaderData = {};\n } else {\n const data = JSON.stringify(loaderData);\n await outputFile(loaderPartialPath, `export function loader(){return ${data}}`);\n const nativeCjs = `exports.loader = function(){return ${data}}`;\n await outputFile(loaderPartialPath.replace(/\\.js$/, \".native.js\"), nativeCjs);\n await outputFile(uncachedNativePath, nativeCjs);\n loaderPath = getLoaderPath(path);\n }\n }\n }\n if (!exported.loader && foundRoute.type === \"spa\") {\n const loaderPartialPath = join(clientDir, urlPathToFilePath(getLoaderPath(path)));\n await outputFile(loaderPartialPath, \"export function loader() { return undefined }\");\n loaderPath = getLoaderPath(path);\n }\n recordTiming(\"pageLoader\", performance.now() - t0);\n matches.push({\n routeId: foundRoute.file,\n pathname: path,\n params: params || {},\n loaderData\n });\n if (foundRoute.type !== \"ssr\") {\n globalThis[\"__vxrnresetState\"]?.();\n if (foundRoute.type === \"ssg\") {\n const renderPreloads = useAfterLCPAggressive ? [] : criticalPreloads || preloads;\n const renderDeferredPreloads = useAfterLCPAggressive ? [] : deferredPreloads;\n t0 = performance.now();\n let html = await render({\n path,\n preloads: renderPreloads,\n deferredPreloads: renderDeferredPreloads,\n loaderProps,\n loaderData,\n css: allCSS,\n cssContents: allCSSContents,\n mode: \"ssg\",\n routePreloads,\n matches\n });\n recordTiming(\"ssrRender\", performance.now() - t0);\n if (useAfterLCP) {\n html = applyAfterLCPScriptLoad(\n html,\n useAfterLCPAggressive ? criticalPreloads || preloads : preloads\n );\n }\n t0 = performance.now();\n await outputFile(htmlOutPath, html);\n recordTiming(\"writeHTML\", performance.now() - t0);\n } else if (foundRoute.type === \"spa\") {\n const needsSpaShell = foundRoute.layouts?.some(\n (layout) => layout.layoutRenderMode === \"ssg\" || layout.layoutRenderMode === \"ssr\"\n );\n if (needsSpaShell) {\n globalThis[\"__vxrnresetState\"]?.();\n const renderPreloads = criticalPreloads || preloads;\n const renderDeferredPreloads = deferredPreloads || [];\n const layoutMatches = matches.slice(0, -1);\n t0 = performance.now();\n let html = await render({\n path,\n preloads: renderPreloads,\n deferredPreloads: renderDeferredPreloads,\n loaderProps,\n // don't pass loaderData for spa-shell - the page loader runs on client\n // passing {} here would make useLoaderState think data is preloaded\n loaderData: void 0,\n css: allCSS,\n cssContents: allCSSContents,\n mode: \"spa-shell\",\n routePreloads,\n matches: layoutMatches\n });\n recordTiming(\"spaShellRender\", performance.now() - t0);\n if (useAfterLCP) {\n html = applyAfterLCPScriptLoad(\n html,\n useAfterLCPAggressive ? criticalPreloads || preloads : preloads\n );\n }\n t0 = performance.now();\n await outputFile(htmlOutPath, html);\n recordTiming(\"writeHTML\", performance.now() - t0);\n } else {\n let renderCSSTag = function(file, index) {\n const content = allCSSContents?.[index];\n if (content) {\n return ` <style>${content}</style>`;\n }\n return ` <link rel=\"stylesheet\" href=${file} />`;\n };\n const layoutCSSSet = new Set(layoutCSS);\n const layoutCssOutput = allCSS.map((file, i) => layoutCSSSet.has(file) ? renderCSSTag(file, i) : \"\").filter(Boolean).join(\"\\n\");\n const pageCssOutput = allCSS.map((file, i) => !layoutCSSSet.has(file) ? renderCSSTag(file, i) : \"\").filter(Boolean).join(\"\\n\");\n const criticalScripts = (criticalPreloads || preloads).map((preload) => ` <script type=\"module\" src=\"${preload}\"></script>`).join(\"\\n\");\n await outputFile(\n htmlOutPath,\n `<!DOCTYPE html><html><head>\n ${constants.getSpaHeaderElements({ serverContext: { loaderProps, loaderData } })}\n ${layoutCssOutput}\n ${criticalScripts}\n ${pageCssOutput}\n </head><body></body></html>`\n );\n }\n }\n }\n } catch (err) {\n const errMsg = err instanceof Error ? `${err.message}\n${err.stack}` : `${err}`;\n console.error(\n `Error building static page at ${path} with id ${relativeId}:\n\n${errMsg}\n\nloaderData:\n\n${JSON.stringify(loaderData || null, null, 2)}\nparams:\n\n${JSON.stringify(params || null, null, 2)}`\n );\n console.error(err);\n throw err;\n }\n const middlewares = (foundRoute.middlewares || []).map(\n (x) => builtMiddlewares[x.contextKey]\n );\n const cleanPath = path === \"/\" ? path : removeTrailingSlash(path);\n return {\n type: foundRoute.type,\n css: allCSS,\n layoutCSS,\n cssContents: allCSSContents,\n routeFile: foundRoute.file,\n middlewares,\n cleanPath,\n preloadPath,\n cssPreloadPath,\n loaderPath,\n clientJsPath,\n serverJsPath: foundRoute.type === \"spa\" ? \"\" : serverJsPath,\n htmlPath,\n loaderData,\n params,\n path,\n preloads,\n criticalPreloads,\n deferredPreloads\n };\n}\nasync function getRender(serverEntry) {\n try {\n const serverImport = await import(toAbsoluteUrl(serverEntry));\n const render = serverImport.default.render || // for an unknown reason this is necessary\n serverImport.default.default?.render;\n if (typeof render !== \"function\") {\n throw new Error(`didn't find render function in entry: ${serverEntry}`);\n }\n return render;\n } catch (err) {\n console.error(`\\u274C Error importing the root entry:`);\n console.error(` This error happened in the built file: ${serverEntry}`);\n console.error(err[\"stack\"]);\n throw err;\n }\n}\nfunction removeTrailingSlash(path) {\n return path.endsWith(\"/\") ? path.slice(0, path.length - 1) : path;\n}\nfunction extractRedirectInfo(response) {\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get(\"location\");\n if (location) {\n try {\n const url = new URL(location);\n return {\n path: url.pathname + url.search + url.hash,\n status: response.status\n };\n } catch {\n return { path: location, status: response.status };\n }\n }\n }\n return null;\n}\nfunction applyAfterLCPScriptLoad(html, preloads) {\n html = html.replace(/<script\\s+type=\"module\"[^>]*async[^>]*><\\/script>/gi, \"\");\n const loaderScript = `\n<script>\n(function() {\n var scripts = ${JSON.stringify(preloads)};\n function loadScripts() {\n scripts.forEach(function(src) {\n var script = document.createElement('script');\n script.type = 'module';\n script.src = src;\n document.head.appendChild(script);\n });\n }\n function waitIdle(n) {\n if (n <= 0) {\n requestAnimationFrame(function() {\n requestAnimationFrame(loadScripts);\n });\n return;\n }\n setTimeout(function() {\n setTimeout(function() {\n waitIdle(n - 1);\n }, 0);\n }, 0);\n }\n waitIdle(5);\n})();\n</script>`;\n html = html.replace(\"</head>\", `${loaderScript}</head>`);\n return html;\n}\nexport {\n buildPage,\n printBuildTimings\n};\n//# sourceMappingURL=buildPage.js.map\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,EAAE,eAAe;AACvB,SAAS,kBAAkB,SAAS;CAClC,MAAM,QAAQ,QAAQ,QAAQ,OAAO,EAAE,CAAC,CAAC,MAAM,GAAG;CAClD,OAAO,KAAK,GAAG,KAAK;AACtB;AACA,MAAM,cAAc,QAAQ,IAAI,qBAAqB;AACrD,MAAM,UAAU,CAAC;AACjB,SAAS,aAAa,OAAO,IAAI;CAC/B,IAAI,CAAC,aAAa;CAClB,CAAC,QAAQ,WAAW,CAAC,EAAC,CAAE,KAAK,EAAE;AACjC;AACA,SAAS,oBAAoB;CAC3B,IAAI,CAAC,aAAa;CAClB,QAAQ,KAAK,8BAAqC;CAClD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,OAAO,GAAG;EACpD,MAAM,QAAQ,MAAM,QAAQ,GAAG,MAAM,IAAI,GAAG,CAAC;EAC7C,MAAM,MAAM,QAAQ,MAAM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