@uniweb/build 0.11.6 → 0.11.7
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 +5 -7
- package/src/vite-foundation-plugin.js +25 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@uniweb/theming": "0.1.3"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@uniweb/runtime": "0.8.
|
|
62
|
-
"@uniweb/content-reader": "1.1.
|
|
61
|
+
"@uniweb/runtime": "0.8.9",
|
|
62
|
+
"@uniweb/content-reader": "1.1.8",
|
|
63
63
|
"@uniweb/schemas": "0.2.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@tailwindcss/vite": "^4.0.0",
|
|
70
70
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
71
71
|
"vite-plugin-svgr": "^4.0.0",
|
|
72
|
-
"@uniweb/core": "0.7.
|
|
72
|
+
"@uniweb/core": "0.7.8"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
75
75
|
"vite": {
|
package/src/prerender.js
CHANGED
|
@@ -11,7 +11,6 @@ import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
|
|
11
11
|
import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
12
12
|
import { join, dirname, resolve } from 'node:path'
|
|
13
13
|
import { pathToFileURL } from 'node:url'
|
|
14
|
-
import { deriveCacheKey } from '@uniweb/core'
|
|
15
14
|
import { executeFetch, mergeDataIntoContent, singularize } from './site/data-fetcher.js'
|
|
16
15
|
import { shouldSplitContent } from './site/split-content.js'
|
|
17
16
|
|
|
@@ -420,6 +419,7 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
420
419
|
// Load shared SSR functions from runtime (lazy — only when prerendering)
|
|
421
420
|
const {
|
|
422
421
|
initPrerender,
|
|
422
|
+
hydrateDataStore,
|
|
423
423
|
prefetchIcons,
|
|
424
424
|
renderPage,
|
|
425
425
|
injectPageContent,
|
|
@@ -557,12 +557,10 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
557
557
|
const uniweb = initPrerender(siteContent, foundation, loadedExtensions, { onProgress })
|
|
558
558
|
|
|
559
559
|
// Build-specific: pre-populate DataStore so EntityStore can resolve data during prerender.
|
|
560
|
-
//
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
}
|
|
560
|
+
// hydrateDataStore handles cache-key derivation + value-shape wrapping
|
|
561
|
+
// — same helper used by the browser SPA boot and by the Cloudflare
|
|
562
|
+
// Worker SSR isolate, so all three render paths agree on shape.
|
|
563
|
+
hydrateDataStore(uniweb.activeWebsite, fetchedData)
|
|
566
564
|
|
|
567
565
|
// Pre-fetch icons for SSR embedding
|
|
568
566
|
await prefetchIcons(siteContent, uniweb, onProgress)
|
|
@@ -42,13 +42,30 @@ async function buildSchemaWithPreviews(srcDir, outDir, isProduction, sectionPath
|
|
|
42
42
|
let _buildingSSRBundle = false
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Build a self-contained ESM bundle for edge SSR (Dynamic Workers).
|
|
45
|
+
* Build a self-contained ESM bundle for edge SSR (Cloudflare Dynamic Workers).
|
|
46
46
|
*
|
|
47
|
-
* Produces
|
|
48
|
-
*
|
|
47
|
+
* Produces `ssr-worker-bundle.js` — a single ESM file with React,
|
|
48
|
+
* ReactDOM/server, `@uniweb/core`, `@uniweb/runtime/ssr`,
|
|
49
|
+
* `@uniweb/theming`, and the foundation's components all inlined. No
|
|
50
|
+
* external imports.
|
|
49
51
|
*
|
|
50
|
-
* This
|
|
51
|
-
*
|
|
52
|
+
* This is **NOT a foundation**. The foundation is `dist/foundation.js`
|
|
53
|
+
* — a foundation-shaped ESM module that externalizes runtime and links
|
|
54
|
+
* to it at runtime, the same as in browser SPA / framework SSG / unipress
|
|
55
|
+
* (Node SSR). This file is something different: a self-contained SSR
|
|
56
|
+
* pipeline shaped for the Cloudflare Workers Dynamic Worker LOADER, with
|
|
57
|
+
* the foundation embedded as one of several inputs. The size ratio
|
|
58
|
+
* (typical ~12× larger than `foundation.js`) reflects what's actually
|
|
59
|
+
* inside it.
|
|
60
|
+
*
|
|
61
|
+
* The artifact is bundled this way because the Dynamic Worker LOADER
|
|
62
|
+
* accepts a closed `modules` map at isolate construction (no external
|
|
63
|
+
* resolver, no path back to npm or R2 for transitive imports). One
|
|
64
|
+
* file in, everything resolves. A future refactor can switch to side-
|
|
65
|
+
* loading runtime + React + core into the modules map separately so
|
|
66
|
+
* foundations stop carrying runtime in their bundles — see
|
|
67
|
+
* `kb/platform/plans/edge-runtime-side-loading.md`. Until then, this
|
|
68
|
+
* build pre-bundles for the isolate's contract.
|
|
52
69
|
*
|
|
53
70
|
* @param {string} outDir - Path to dist/ directory containing foundation.js
|
|
54
71
|
*/
|
|
@@ -142,7 +159,7 @@ async function buildSSRBundle(outDir) {
|
|
|
142
159
|
bundle: true,
|
|
143
160
|
format: 'esm',
|
|
144
161
|
platform: 'browser',
|
|
145
|
-
outfile: join(outDir, '
|
|
162
|
+
outfile: join(outDir, 'ssr-worker-bundle.js'),
|
|
146
163
|
minify: false,
|
|
147
164
|
external: [],
|
|
148
165
|
nodePaths,
|
|
@@ -151,9 +168,9 @@ async function buildSSRBundle(outDir) {
|
|
|
151
168
|
logLevel: 'warning',
|
|
152
169
|
})
|
|
153
170
|
|
|
154
|
-
const ssrFile = join(outDir, '
|
|
171
|
+
const ssrFile = join(outDir, 'ssr-worker-bundle.js')
|
|
155
172
|
const size = (statSync(ssrFile).size / 1024).toFixed(1)
|
|
156
|
-
console.log(`Generated
|
|
173
|
+
console.log(`Generated ssr-worker-bundle.js (${size} KB)`)
|
|
157
174
|
} catch (err) {
|
|
158
175
|
console.warn(`Warning: SSR bundle build failed: ${err.message}`)
|
|
159
176
|
} finally {
|