@takazudo/zfb-adapter-cloudflare 0.1.0-next.52 → 0.1.0-next.54
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/dist/worker-wrapper.mjs +11 -2
- package/package.json +1 -1
- package/src/worker-wrapper.mjs +11 -2
package/dist/worker-wrapper.mjs
CHANGED
|
@@ -31,8 +31,7 @@ export const WORKER_WRAPPER_SOURCE = `// AUTO-GENERATED by @takazudo/zfb-adapter
|
|
|
31
31
|
// islands-…">). If we let the inner Hono router handle them first,
|
|
32
32
|
// it would dynamic-SSR the page WITHOUT the prod head injection
|
|
33
33
|
// (which is a build-time post-process, not a runtime concern), and
|
|
34
|
-
// islands would never hydrate.
|
|
35
|
-
// the zudo-doc#1355 zfb-pipeline-gaps epic).
|
|
34
|
+
// islands would never hydrate.
|
|
36
35
|
// - On 404 from ASSETS, fall through to the inner zfb worker. This is
|
|
37
36
|
// where genuinely dynamic routes (\`prerender = false\`, e.g.
|
|
38
37
|
// \`pages/api/*.tsx\`) are served.
|
|
@@ -68,6 +67,16 @@ function isAssetProbeMethod(method) {
|
|
|
68
67
|
export default {
|
|
69
68
|
async fetch(request, env, ctx) {
|
|
70
69
|
if (isAssetProbeMethod(request.method) && canDelegateToAssets(env)) {
|
|
70
|
+
// Trade-off: every GET/HEAD request that matches a prerendered route pays
|
|
71
|
+
// the cost of one env.ASSETS.fetch() round-trip before the inner worker
|
|
72
|
+
// sees it. The upside is that CF Pages' asset server handles trailing-
|
|
73
|
+
// slash canonicalisation (e.g. /docs/foo → 308 → /docs/foo/) and serves
|
|
74
|
+
// the build-time head-injected HTML with the hashed <link>/<script> tags.
|
|
75
|
+
// If we skipped this probe, prerendered routes would be dynamic-SSR'd by
|
|
76
|
+
// the inner Hono router without the prod head injection, and islands would
|
|
77
|
+
// never hydrate. For purely dynamic apps (prerender=false everywhere) the
|
|
78
|
+
// extra round-trip is pure overhead; splitting the wrapper into two
|
|
79
|
+
// variants is the accepted future escape hatch for that case.
|
|
71
80
|
const assetResponse = await env.ASSETS.fetch(request);
|
|
72
81
|
if (assetResponse.status !== 404) {
|
|
73
82
|
return assetResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zfb-adapter-cloudflare",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.54",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Rust-built static-site engine for Astro and Next.js users — millisecond rebuilds, single binary. Cloudflare Pages adapter.",
|
package/src/worker-wrapper.mjs
CHANGED
|
@@ -31,8 +31,7 @@ export const WORKER_WRAPPER_SOURCE = `// AUTO-GENERATED by @takazudo/zfb-adapter
|
|
|
31
31
|
// islands-…">). If we let the inner Hono router handle them first,
|
|
32
32
|
// it would dynamic-SSR the page WITHOUT the prod head injection
|
|
33
33
|
// (which is a build-time post-process, not a runtime concern), and
|
|
34
|
-
// islands would never hydrate.
|
|
35
|
-
// the zudo-doc#1355 zfb-pipeline-gaps epic).
|
|
34
|
+
// islands would never hydrate.
|
|
36
35
|
// - On 404 from ASSETS, fall through to the inner zfb worker. This is
|
|
37
36
|
// where genuinely dynamic routes (\`prerender = false\`, e.g.
|
|
38
37
|
// \`pages/api/*.tsx\`) are served.
|
|
@@ -68,6 +67,16 @@ function isAssetProbeMethod(method) {
|
|
|
68
67
|
export default {
|
|
69
68
|
async fetch(request, env, ctx) {
|
|
70
69
|
if (isAssetProbeMethod(request.method) && canDelegateToAssets(env)) {
|
|
70
|
+
// Trade-off: every GET/HEAD request that matches a prerendered route pays
|
|
71
|
+
// the cost of one env.ASSETS.fetch() round-trip before the inner worker
|
|
72
|
+
// sees it. The upside is that CF Pages' asset server handles trailing-
|
|
73
|
+
// slash canonicalisation (e.g. /docs/foo → 308 → /docs/foo/) and serves
|
|
74
|
+
// the build-time head-injected HTML with the hashed <link>/<script> tags.
|
|
75
|
+
// If we skipped this probe, prerendered routes would be dynamic-SSR'd by
|
|
76
|
+
// the inner Hono router without the prod head injection, and islands would
|
|
77
|
+
// never hydrate. For purely dynamic apps (prerender=false everywhere) the
|
|
78
|
+
// extra round-trip is pure overhead; splitting the wrapper into two
|
|
79
|
+
// variants is the accepted future escape hatch for that case.
|
|
71
80
|
const assetResponse = await env.ASSETS.fetch(request);
|
|
72
81
|
if (assetResponse.status !== 404) {
|
|
73
82
|
return assetResponse;
|