@uniweb/build 0.37.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/prerender.js +27 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"yaml": "^2.5.0",
|
|
62
62
|
"@uniweb/content-writer": "^0.3.4",
|
|
63
63
|
"@uniweb/content-reader": "^1.2.4",
|
|
64
|
+
"@uniweb/semantic-parser": "^1.4.0",
|
|
64
65
|
"@uniweb/projections": "^0.5.7",
|
|
65
66
|
"@uniweb/schemas": "^0.2.13",
|
|
66
|
-
"@uniweb/theming": "^0.1.15"
|
|
67
|
-
"@uniweb/semantic-parser": "^1.4.0"
|
|
67
|
+
"@uniweb/theming": "^0.1.15"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@uniweb/runtime": "^0.14.
|
|
70
|
+
"@uniweb/runtime": "^0.14.2"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
package/src/prerender.js
CHANGED
|
@@ -567,8 +567,7 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
567
567
|
initPrerender,
|
|
568
568
|
hydrateDataStore,
|
|
569
569
|
prefetchIcons,
|
|
570
|
-
|
|
571
|
-
injectPageContent,
|
|
570
|
+
createPageRenderer,
|
|
572
571
|
generate404Html,
|
|
573
572
|
} = await import('@uniweb/runtime/ssr')
|
|
574
573
|
|
|
@@ -702,6 +701,10 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
702
701
|
// Initialize the Uniweb runtime using the shared SSR module
|
|
703
702
|
const uniweb = initPrerender(siteContent, foundation, loadedExtensions, { onProgress })
|
|
704
703
|
|
|
704
|
+
// One renderer for this run: the Website is already built and the shell is
|
|
705
|
+
// fixed, so it is created once and asked per page.
|
|
706
|
+
const renderer = createPageRenderer({ website: uniweb.activeWebsite, shell: htmlShell })
|
|
707
|
+
|
|
705
708
|
// Build-specific: pre-populate DataStore so EntityStore can resolve data during prerender.
|
|
706
709
|
// hydrateDataStore handles cache-key derivation + value-shape wrapping
|
|
707
710
|
// — same helper used by the browser SPA boot and by the Cloudflare
|
|
@@ -765,28 +768,37 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
765
768
|
|
|
766
769
|
onProgress(`Rendering ${outputRoute}...`)
|
|
767
770
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
771
|
+
// ⭐ `renderer.render` IS the sequence this loop used to spell out —
|
|
772
|
+
// renderPage → classify → injectPageContent. It was moved into
|
|
773
|
+
// `@uniweb/runtime/ssr` because an SSR isolate assembles the same three steps
|
|
774
|
+
// per request, and two hand-written copies of one sequence is how the two
|
|
775
|
+
// lanes drift. This lane passes the Page it already holds; the isolate passes
|
|
776
|
+
// a route. See `runtime/src/page-renderer.js` for what it leaves to the host.
|
|
777
|
+
const result = renderer.render(page)
|
|
778
|
+
|
|
779
|
+
if (result.outcome === 'failed') {
|
|
780
|
+
const { type, message } = result.error
|
|
781
|
+
if (type === 'hooks' || type === 'null-component') {
|
|
772
782
|
console.warn(
|
|
773
|
-
` Skipped SSG for ${outputRoute} — ${
|
|
783
|
+
` Skipped SSG for ${outputRoute} — ${message}. ` +
|
|
774
784
|
`The page will render correctly client-side.`
|
|
775
785
|
)
|
|
776
786
|
} else {
|
|
777
|
-
console.warn(` Warning: Failed to render ${outputRoute}: ${
|
|
787
|
+
console.warn(` Warning: Failed to render ${outputRoute}: ${message}`)
|
|
778
788
|
}
|
|
789
|
+
continue
|
|
790
|
+
}
|
|
779
791
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
792
|
+
// ⛔ `notFound` cannot happen here — this loop iterates pages it already has,
|
|
793
|
+
// so `render` never resolves. Handled anyway: silently writing nothing for a
|
|
794
|
+
// page the loop selected would be the same shape of empty-success bug that
|
|
795
|
+
// `renderPage`'s content-not-loaded guard exists to catch.
|
|
796
|
+
if (result.outcome === 'notFound') {
|
|
797
|
+
console.warn(` Warning: ${outputRoute} resolved to no page; skipped`)
|
|
783
798
|
continue
|
|
784
799
|
}
|
|
785
800
|
|
|
786
|
-
|
|
787
|
-
let html = injectPageContent(htmlShell, result.renderedContent, page, {
|
|
788
|
-
sectionOverrideCSS: result.sectionOverrideCSS,
|
|
789
|
-
})
|
|
801
|
+
let html = result.html
|
|
790
802
|
|
|
791
803
|
// Build-specific: theme CSS, __SITE_CONTENT__, icon cache.
|
|
792
804
|
// scopeRoutes mirrors the runtime data cascade (page → page.parent → site)
|