@octanejs/adapter-cloudflare 0.0.44 → 0.0.46
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 +6 -6
- package/src/adapt.js +26 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/adapter-cloudflare",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@octanejs/app-core": "0.0.
|
|
40
|
+
"@octanejs/app-core": "0.0.52"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@rsbuild/core": "^2.1.6",
|
|
44
44
|
"@types/node": "^24.13.3",
|
|
45
45
|
"miniflare": "4.20260714.0",
|
|
46
46
|
"vite": "^8.1.5",
|
|
47
|
-
"@octanejs/app-core": "0.0.
|
|
48
|
-
"@octanejs/
|
|
49
|
-
"@octanejs/
|
|
50
|
-
"octane": "0.
|
|
47
|
+
"@octanejs/app-core": "0.0.52",
|
|
48
|
+
"@octanejs/vite-plugin": "0.1.56",
|
|
49
|
+
"@octanejs/rsbuild-plugin": "0.1.51",
|
|
50
|
+
"octane": "0.3.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/adapt.js
CHANGED
|
@@ -21,10 +21,17 @@ const GENERATED_WORKER_HEADER = '// Auto-generated by @octanejs/adapter-cloudfla
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {string} htmlTemplate
|
|
23
23
|
* @param {Record<string, unknown> | undefined} clientAssets
|
|
24
|
+
* @param {Record<string, unknown> | undefined} clientBuild
|
|
25
|
+
* @param {Record<string, unknown> | undefined} independentHydration
|
|
24
26
|
* @returns {string}
|
|
25
27
|
*/
|
|
26
|
-
function generateWorkerSource(htmlTemplate, clientAssets) {
|
|
27
|
-
const options = {
|
|
28
|
+
function generateWorkerSource(htmlTemplate, clientAssets, clientBuild, independentHydration) {
|
|
29
|
+
const options = {
|
|
30
|
+
htmlTemplate,
|
|
31
|
+
...(clientAssets === undefined ? null : { clientAssets }),
|
|
32
|
+
...(clientBuild === undefined ? null : { clientBuild }),
|
|
33
|
+
...(independentHydration === undefined ? null : { independentHydration }),
|
|
34
|
+
};
|
|
28
35
|
return `${GENERATED_WORKER_HEADER} — do not edit.
|
|
29
36
|
import { createWebWorkerHandler } from './entry.js';
|
|
30
37
|
|
|
@@ -72,13 +79,29 @@ export async function emitCloudflareWorker(ctx) {
|
|
|
72
79
|
const clientAssets = existsSync(clientAssetMap)
|
|
73
80
|
? JSON.parse(readFileSync(clientAssetMap, 'utf-8'))
|
|
74
81
|
: undefined;
|
|
82
|
+
const clientBuildFile = join(serverDir, 'octane-client-build.json');
|
|
83
|
+
// This is required completed-build authority, unlike the optional asset map.
|
|
84
|
+
// Fail at adaptation instead of publishing a Worker that fails on its first request.
|
|
85
|
+
const clientBuild = JSON.parse(readFileSync(clientBuildFile, 'utf-8'));
|
|
86
|
+
const independentHydrationFile = join(serverDir, 'octane-independent-hydration.json');
|
|
87
|
+
const independentHydration = existsSync(independentHydrationFile)
|
|
88
|
+
? JSON.parse(readFileSync(independentHydrationFile, 'utf-8'))
|
|
89
|
+
: undefined;
|
|
75
90
|
const output = join(serverDir, WORKER_ENTRY);
|
|
76
91
|
if (existsSync(output) && !readFileSync(output, 'utf-8').startsWith(GENERATED_WORKER_HEADER)) {
|
|
77
92
|
throw new Error(
|
|
78
93
|
`[@octanejs/adapter-cloudflare] Refusing to replace ${output}: the server build already emitted worker.js. Configure asynchronous server chunks under a subdirectory.`,
|
|
79
94
|
);
|
|
80
95
|
}
|
|
81
|
-
writeFileSync(
|
|
96
|
+
writeFileSync(
|
|
97
|
+
output,
|
|
98
|
+
generateWorkerSource(
|
|
99
|
+
readFileSync(htmlTemplate, 'utf-8'),
|
|
100
|
+
clientAssets,
|
|
101
|
+
clientBuild,
|
|
102
|
+
independentHydration,
|
|
103
|
+
),
|
|
104
|
+
);
|
|
82
105
|
|
|
83
106
|
log(
|
|
84
107
|
`[@octanejs/adapter-cloudflare] Worker entry written to ${join(ctx.outDir, 'server', WORKER_ENTRY)}`,
|