Zod 4 safeParse does not bundle with Shopify CLI correctly

I’m using zod version 4 "zod": "4.0" in my Shopify POS UI Extension but when the Shopify CLI bundles it for distribution it breaks safeParse

I made a minimal example outside of Shopify CLI and used rollup to bundle zod 4 and it worked. So I know it’s something about how Shopify CLI is bundling.

You can easily reproduce by running this line of code anywhere during load

const myConst = {
    input: z.object({ orderName: z.string() }),
    output: z.object({ orderId: z.string() }),
  };


  const result = myConst.input.safeParse(data);

The error message you will receive is:
Error in input TypeError: Cannot read properties of undefined (reading 'issues')

If it helps, here is the generated code in dist/ that is causing issues

function _safeParse(schema, value, _ctx) {
        var _a;
        const ctx = _ctx ? __spreadProps(__spreadValues({}, _ctx), { async: false }) : { async: false };
        const result = schema._zod.run({ value, issues: [] }, ctx);
        if (result instanceof Promise) {
          throw new core.$ZodAsyncError();
        }
        return result.issues.length ? {
          success: false,
          error: new ((_a = this == null ? void 0 : this.Error) != null ? _a : errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())))
        } : { success: true, data: result.value };
      }