@guren/plugin-cloudflare 0.10.1 → 0.11.0
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import { AGENTS_CONFIG_FILE, DATABASE_FACTORIES, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_PLUGIN_PACKAGE, MCP_TRANSPORT_SPECIFIER, SQL_CLIENT_MODULES, appUsesMcpPlugin, assertOutputDirOutsideRoot,
|
|
4
|
+
import { AGENTS_CONFIG_FILE, DATABASE_FACTORIES, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_PLUGIN_PACKAGE, MCP_TRANSPORT_SPECIFIER, SQL_CLIENT_MODULES, appUsesMcpPlugin, assertOutputDirOutsideRoot, bundledRuntimeEnv, detectDatabaseDialects, importSpecifier, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, stageStaticAssets, stubbableDevOnlyModules } from "@guren/core/internal/deploy-build";
|
|
5
5
|
import { reportDeployRuntimeHazards } from "@guren/core/internal/deploy-check";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
//#region src/templates.ts
|
|
@@ -77,13 +77,13 @@ async function buildCloudflareOutput(options = {}) {
|
|
|
77
77
|
if (!existsSync(appEntry)) throw new Error(`Cloudflare build: app entry not found at ${appEntry}. Pass "appEntry" if your Application lives elsewhere.`);
|
|
78
78
|
const ssrImport = await resolveSsrImport(ssrDir, ssrEntryKey);
|
|
79
79
|
const assetEnv = resolveClientAssetEnv(publicDir, clientEntryKey, "Cloudflare build");
|
|
80
|
-
const
|
|
80
|
+
const bundledEnv = bundledRuntimeEnv(root, publicDir, "Cloudflare build");
|
|
81
81
|
resetOutputDir(out, root, "Cloudflare build");
|
|
82
82
|
stageStaticAssets(publicDir, resolve(out, "assets"));
|
|
83
83
|
writeAssetHeaders(resolve(out, "assets"));
|
|
84
84
|
const workerEnv = renderWorkerEnvModule({
|
|
85
85
|
assetEnv,
|
|
86
|
-
|
|
86
|
+
bundledEnv
|
|
87
87
|
});
|
|
88
88
|
if (workerEnv) writeFileSync(resolve(out, "worker-env.js"), workerEnv);
|
|
89
89
|
writeFileSync(resolve(out, "worker.js"), renderWorkerModule({
|
|
@@ -653,7 +653,7 @@ function renderWorkerEnvModule(input) {
|
|
|
653
653
|
const lines = [];
|
|
654
654
|
if (input.assetEnv.entry) lines.push(`process.env.GUREN_INERTIA_ENTRY = ${JSON.stringify(input.assetEnv.entry)}`);
|
|
655
655
|
if (input.assetEnv.styles) lines.push(`process.env.GUREN_INERTIA_STYLES = ${JSON.stringify(input.assetEnv.styles)}`);
|
|
656
|
-
|
|
656
|
+
for (const [key, value] of Object.entries(input.bundledEnv)) lines.push(`process.env.${key} = ${JSON.stringify(value)}`);
|
|
657
657
|
if (lines.length === 0) return;
|
|
658
658
|
return [
|
|
659
659
|
"// Generated by `guren cloudflare:build`. Do not edit — regenerate instead.",
|
package/dist/commands.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as printBundleReport, c as buildCloudflareOutput, s as reportBundleSize } from "./bundle-size-
|
|
1
|
+
import { a as printBundleReport, c as buildCloudflareOutput, s as reportBundleSize } from "./bundle-size-B-2cTytq.js";
|
|
2
2
|
import { defineCommand } from "citty";
|
|
3
3
|
//#region src/commands.ts
|
|
4
4
|
const rootArg = {
|
package/dist/index.d.ts
CHANGED
|
@@ -20,9 +20,14 @@ interface WorkersScheduledEvent {
|
|
|
20
20
|
interface WorkersAppLike {
|
|
21
21
|
boot(): Promise<void>;
|
|
22
22
|
fetch(request: Request, env?: unknown, executionCtx?: unknown): Response | Promise<Response>;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Read by the cron entrypoint. `has`/`instance` bind the entrypoint env as
|
|
25
|
+
* `env.source` before boot (RFC 0027 §1); optional, so an existing app-like still boots.
|
|
26
|
+
*/
|
|
24
27
|
container?: {
|
|
25
28
|
makeOptional<T>(key: string): T | undefined;
|
|
29
|
+
has?(key: string): boolean;
|
|
30
|
+
instance?(key: string, value: unknown): unknown;
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { captureWorkersEnv, getWorkersEnv, isWorkersRuntime, resetWorkersEnv } from "./env.js";
|
|
2
|
-
import { a as printBundleReport, c as buildCloudflareOutput, i as parseWranglerSize, l as flattenD1Migrations, n as WORKER_SIZE_WARN_SHARE, o as renderBundleReport, r as attributeBundle, s as reportBundleSize, t as WORKER_SIZE_LIMIT } from "./bundle-size-
|
|
2
|
+
import { a as printBundleReport, c as buildCloudflareOutput, i as parseWranglerSize, l as flattenD1Migrations, n as WORKER_SIZE_WARN_SHARE, o as renderBundleReport, r as attributeBundle, s as reportBundleSize, t as WORKER_SIZE_LIMIT } from "./bundle-size-B-2cTytq.js";
|
|
3
3
|
import { definePlugin } from "@guren/core";
|
|
4
4
|
//#region src/boot.ts
|
|
5
5
|
const latches = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
/** Wrangler `vars` may be missing from `process.env`; a value the app or a test bound itself is kept. */
|
|
7
|
+
function bindEnvSource(app, env) {
|
|
8
|
+
const container = app.container;
|
|
9
|
+
if (!container?.has || !container.instance || env === null || typeof env !== "object") return;
|
|
10
|
+
if (!container.has("env.source")) container.instance("env.source", env);
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* Boot `app` against `env`, once per isolate.
|
|
8
14
|
*
|
|
@@ -16,6 +22,7 @@ async function bootWorkersApp(app, env) {
|
|
|
16
22
|
try {
|
|
17
23
|
attempt = latches.get(app);
|
|
18
24
|
if (!attempt) {
|
|
25
|
+
bindEnvSource(app, env);
|
|
19
26
|
attempt = app.boot();
|
|
20
27
|
latches.set(app, attempt);
|
|
21
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/plugin-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@guren/core": "^1.
|
|
50
|
+
"@guren/core": "^1.19.0",
|
|
51
51
|
"citty": "^0.1.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|