@decocms/start 0.36.1 → 0.36.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "0.36.1",
3
+ "version": "0.36.2",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./src/index.ts",
@@ -60,7 +60,7 @@ export function generatePackageJson(ctx: MigrationContext): string {
60
60
 
61
61
  // Fetch latest versions from npm registry
62
62
  const startVersion = getLatestVersion("@decocms/start", "0.34.0");
63
- const appsVersion = getLatestVersion("@decocms/apps", "0.26.0");
63
+ const appsVersion = getLatestVersion("@decocms/apps", "0.27.0");
64
64
 
65
65
  const pkg = {
66
66
  name: ctx.siteName,
@@ -46,17 +46,35 @@ interface AppMod {
46
46
  handlers: Record<string, (props: any, request: Request) => Promise<any>>;
47
47
  }
48
48
 
49
+ /**
50
+ * Import app mod using static imports.
51
+ * CF Workers can't catch errors from dynamic string template imports —
52
+ * the vite plugin crashes with AssertionError before the catch runs.
53
+ * Each known app gets a case here. When adding a new app to BLOCK_TO_APP,
54
+ * also add a case to this switch.
55
+ */
56
+ async function importAppMod(appName: string): Promise<AppMod | null> {
57
+ try {
58
+ switch (appName) {
59
+ case "resend":
60
+ return await import("@decocms/apps/resend/mod");
61
+ default:
62
+ return null;
63
+ }
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+
49
69
  async function loadAndConfigureApp(
50
70
  blockKey: string,
51
71
  appName: string,
52
72
  blockData: unknown,
53
73
  ): Promise<Record<string, InvokeAction>> {
54
- try {
55
- // Dynamic import of @decocms/apps/{appName}/mod
56
- const mod: AppMod = await import(
57
- /* @vite-ignore */ `@decocms/apps/${appName}/mod`
58
- );
74
+ const mod = await importAppMod(appName);
75
+ if (!mod) return {};
59
76
 
77
+ try {
60
78
  const ok = await mod.configure(blockData, resolveSecret);
61
79
  if (!ok) {
62
80
  console.warn(
@@ -69,10 +87,6 @@ async function loadAndConfigureApp(
69
87
  console.log(`[autoconfig] ${blockKey}: configured (${Object.keys(mod.handlers).length} handlers)`);
70
88
  return mod.handlers;
71
89
  } catch (e) {
72
- // @decocms/apps not installed or app module doesn't exist — skip silently
73
- if ((e as any)?.code === "ERR_MODULE_NOT_FOUND" || (e as any)?.message?.includes("Cannot find")) {
74
- return {};
75
- }
76
90
  console.warn(`[autoconfig] ${blockKey}:`, e);
77
91
  return {};
78
92
  }