Skip to content

zod fails to compile under perry.compilePackages: cross-module class re-exports unresolved #836

Description

@proggeramlug

Surfaced by the new npm-package sweep harness (`scripts/npm_compile_sweep.sh`, added under #805). zod is in the tier1 list — high-leverage "should compile today" target.

Repro

```bash
mkdir /tmp/perry-zod && cd /tmp/perry-zod
cat > package.json <<'JSON'
{"name":"d","private":true,"type":"module","dependencies":{"zod":"*"},"perry":{"compilePackages":["zod"]}}
JSON
npm install
cat > main.ts <<'TS'
import { z } from "zod";
console.log(z.object({ a: z.string() }).parse({ a: 'hi' }).a);
TS
perry main.ts -o out
```

Failure mode (v0.5.914)

Link step emits dozens of undefined symbols. The instructive ones:

```
"___perry_wrap_perry_fn_node_modules_zod_src_index_ts__z", referenced from:
_main in main_ts.o
"___perry_wrap_perry_fn_node_modules_zod_src_v4_core_regexes_ts__null", referenced from:
_perry_closure_node_modules_zod_src_v4_core_schemas_ts__98 in node_modules_zod_src_v4_core_schemas_ts.o
"___perry_wrap_perry_fn_node_modules_zod_src_v4_core_regexes_ts__undefined", referenced from:
perry_closure_node_modules_zod_src_v4_core_schemas_ts__96 in node_modules_zod_src_v4_core_schemas_ts.o
"perry_fn_node_modules_zod_src_v4_core_checks_ts
\$ZodCheck", referenced from:
perry_closure_node_modules_zod_src_v4_core_schemas_ts__323 in node_modules_zod_src_v4_core_schemas_ts.o
"perry_fn_node_modules_zod_src_v4_core_core_ts
\$constructor", referenced from:
_node_modules_zod_src_v4_classic_errors_ts__init in node_modules_zod_src_v4_classic_errors_ts.o
```

Two distinct sub-bugs in the same repro

  1. `__regexes_ts__null` / `__regexes_ts__undefined` — zod's `regexes.ts` re-exports patterns under names like `null` and `undefined`. Perry's codegen emits `_perry_wrap_perry_fn__null` references but the producing module never emits the corresponding definition (likely the codegen treats `null`/`undefined` as keywords and skips defining the wrapper). Renaming the exports in user code shouldn't be necessary — zod is unmodified.

  2. `core_checks_ts$ZodCheck` etc — class symbols prefixed with `$`. These look like the same class-export-not-resolved family as Linker: unresolved _perry_fn_..._render for V8-fallback modules referenced from main #678 (V8-fallback / re-export rename) and fix(codegen): #678 — re-export rename resolves to origin export name #785 (re-export origin name). But the failing module is the producer (`core/checks.ts`), not the re-exporting layer, so this is a different breakage.

Suggested triage

The npm-sweep CSV will pick up regressions/improvements automatically once this lands. Tier1 should reach pass once both sub-bugs close.

Part of #793 + #805. Surfaced by the #805 sweep harness on its first tier1 run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions