@guren/plugin-cloudflare 0.12.1 → 0.12.3

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.
@@ -54,6 +54,7 @@ async function buildCloudflareOutput(options = {}) {
54
54
  const ssrEntryKey = options.ssrEntryKey ?? "resources/js/ssr.tsx";
55
55
  assertOutputDirOutsideRoot(out, root, "Cloudflare build");
56
56
  assertWranglerJsoncIsAuthoritative(root);
57
+ assertKeepsClassNames(root);
57
58
  const packageJson = readPackageJson(root);
58
59
  const mcpOAuth = options.mcpOAuth === true;
59
60
  const mcpPath = options.mcpPath ?? DEFAULT_MCP_PATH;
@@ -308,10 +309,22 @@ function configScopes(config) {
308
309
  }
309
310
  return scopes;
310
311
  }
311
- /** One scope's verdict: mangling refused, every registered class bound and SQLite-backed. */
312
+ /**
313
+ * wrangler bundles with esbuild's `keepNames: keep_names ?? true`, on deploy and in
314
+ * dev, so `minify` alone keeps class names and only `"keep_names": false` loses them.
315
+ * Every app is refused, not only one hosting agents: jobs, events and notifications
316
+ * are keyed by class name too. An unparseable config is reported by the scaffold step.
317
+ */
318
+ function assertKeepsClassNames(root) {
319
+ const configPath = resolve(root, "wrangler.jsonc");
320
+ const config = readWranglerConfig(configPath);
321
+ if (!config) return;
322
+ const refused = configScopes(config).find((scope) => scope.config.keep_names === false);
323
+ if (refused) throw new Error(`Cloudflare build: ${configPath}${refused.label} sets "keep_names": false. Guren finds a durable agent by its class name, and stores queued jobs, queued events and notifications under theirs unless they pin "static jobName", "static eventName" or a "type" getter. With keep_names off, esbuild renames classes: every class under "minify", and otherwise any top-level class sharing its name with one in another module (two OrderShipped classes bundle as OrderShipped and OrderShipped2). The deploy succeeds, and records the previous deploy wrote stop resolving. Remove "keep_names" from the config (wrangler defaults it to true), or set it to true.`);
324
+ }
325
+ /** One scope's verdict: every registered class bound and SQLite-backed. */
312
326
  function assertAgentScopeHosts(configPath, scope, topLevel, agents) {
313
327
  const where = `${configPath}${scope.label}`;
314
- if ((scope.config.minify ?? topLevel.minify) === true) throw new Error(`Cloudflare build: ${where} sets "minify": true, and this app hosts agents. wrangler's minifier renames identifiers, and an agent class is looked up by its runtime name — mangled, every tool call fails with "is not registered" after a deploy that looked fine. Remove "minify" from the config.`);
315
328
  const bound = new Set(registeredBindings(scope.config, agents).map((binding) => binding.class_name));
316
329
  const sqlite = sqliteBackedClasses(Array.isArray(scope.config.migrations) || isRecord(scope.config.exports) ? scope.config : topLevel);
317
330
  const unbound = agents.filter((agent) => !bound.has(agent.export));
package/dist/commands.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as printBundleReport, c as buildCloudflareOutput, s as reportBundleSize } from "./bundle-size-i1kLeIiR.js";
1
+ import { a as printBundleReport, c as buildCloudflareOutput, s as reportBundleSize } from "./bundle-size-CUn3w_nY.js";
2
2
  import { defineCommand } from "citty";
3
3
  //#region src/commands.ts
4
4
  const rootArg = {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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-i1kLeIiR.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-CUn3w_nY.js";
3
3
  import { definePlugin } from "@guren/core";
4
4
  //#region src/boot.ts
5
5
  const latches = /* @__PURE__ */ new WeakMap();
@@ -463,7 +463,8 @@ function trimSlashes(value) {
463
463
  //#region src/index.ts
464
464
  const factory = definePlugin({
465
465
  name: "cloudflare",
466
- register() {}
466
+ register() {},
467
+ introspect() {}
467
468
  });
468
469
  /** Register the Cloudflare plugin: `createApp({ providers: [cloudflarePlugin()] })`. */
469
470
  function cloudflarePlugin(config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/plugin-cloudflare",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Deploy a Guren application to Cloudflare Workers, with D1 as the database.",
5
5
  "keywords": [
6
6
  "guren",
@@ -59,7 +59,7 @@
59
59
  "typecheck": "tsc --noEmit"
60
60
  },
61
61
  "dependencies": {
62
- "@guren/core": "^1.20.1",
62
+ "@guren/core": "^1.22.0",
63
63
  "citty": "^0.1.6"
64
64
  },
65
65
  "devDependencies": {