Struggling to deploy to Mastra Cloud
I've been trying to decouple my Mastra instance from my main Nextjs app, to deploy it to Mastra Cloud. It's been very difficult. I have a number of hacks that I'm not happy with, but right now the one I'm stuck on is this:
INFO [2025-11-14 19:14:36.790 +0000] (Mastra CLI): Analyzing dependencies...
INFO [2025-11-14 19:14:42.327 +0000] (Mastra CLI): Optimizing dependencies...
INFO [2025-11-14 19:15:17.755 +0000] (Mastra CLI): Bundling Mastra application
WARN [2025-11-14 19:15:20.837 +0000] (Mastra CLI): Circular dependency found:
\t.mastra/.build/zod-v4.mjs -> .mastra/.build/zod-v4.mjs
WARN [2025-11-14 19:15:20.837 +0000] (Mastra CLI): Circular dependency found:
\t.mastra/.build/zod-v3.mjs -> .mastra/.build/zod-v3.mjs
ERROR [2025-11-14 19:15:21.319 +0000] (Mastra CLI): Failed during bundler bundle stage: "ZodFirstPartyTypeKind" cannot be exported from ".mastra/.build/zod-v3.mjs" as it is a reexport that references itself.
domain: "DEPLOYER"
category: "SYSTEM"
details: {}
I use Zod v4 in the rest of my app, but there are some internal v3 references to Mastra. The Mastra bundler has some settings (that I don't think I can control) that are really causing for a painful experience in managing bundling.
Is there something I'm missing there?
INFO [2025-11-14 19:14:36.790 +0000] (Mastra CLI): Analyzing dependencies...
INFO [2025-11-14 19:14:42.327 +0000] (Mastra CLI): Optimizing dependencies...
INFO [2025-11-14 19:15:17.755 +0000] (Mastra CLI): Bundling Mastra application
WARN [2025-11-14 19:15:20.837 +0000] (Mastra CLI): Circular dependency found:
\t.mastra/.build/zod-v4.mjs -> .mastra/.build/zod-v4.mjs
WARN [2025-11-14 19:15:20.837 +0000] (Mastra CLI): Circular dependency found:
\t.mastra/.build/zod-v3.mjs -> .mastra/.build/zod-v3.mjs
ERROR [2025-11-14 19:15:21.319 +0000] (Mastra CLI): Failed during bundler bundle stage: "ZodFirstPartyTypeKind" cannot be exported from ".mastra/.build/zod-v3.mjs" as it is a reexport that references itself.
domain: "DEPLOYER"
category: "SYSTEM"
details: {}
I use Zod v4 in the rest of my app, but there are some internal v3 references to Mastra. The Mastra bundler has some settings (that I don't think I can control) that are really causing for a painful experience in managing bundling.
Is there something I'm missing there?