Skip to content

[finding] After sideEffects:false + PURE-marked lazySchema/strictObject/defineForm, a /security one-predicate import still retains ~174 KB minified — top-level z.* chain constructions are the unshakeable residue #10200

Description

@qq9340100

Measured while landing #10031 (branch claude/issue-10096-schema-free-meta-spelling @a9be45a86); filed unassigned as an observation — the #10031 verification criterion (delta reproduced shrinking) is met, this records what the chosen instrument cannot reach.

What was measured

esbuild --bundle --minify --format=esm --platform=browser --external:fs, probe importing only postureEnforcesWall from @objectstack/spec/security, workspace spec dist:

stateroot + /security marginal (min)(gz)
origin/main @cc21aad8e+261.5 KB+82.4 KB
after sideEffects: false + PURE-marked lazySchema+202.0 KB+63.8 KB
+ PURE-marked strictObject, defineForm+177.8 KB+56.6 KB

Identical in both graph directions (/ui + /security gives the same marginal), same as the card's original observation.

Why the residue resists name-based PURE marking

The tsup esbuild onLoad transform annotates call sites by callee name, which only makes a top-level statement droppable when EVERY call in the initializer is annotated. The dist/security/index.mjs survey (pre-annotation) counted, at top level: 109 lazySchema( (now annotated), 27 z.enum(, 5 z.object(, 4 z.union(, 4 z.string(, 4 z.lazy(, 1 z.discriminatedUnion(, 9 strictObject( and 1 defineForm( (now annotated). The z.* sites are mostly CHAINED (z.enum([...]).describe(...)) — the outermost call is a method on an intermediate result, which no callee-name list can mark, so the statement and everything it transitively retains (zod core included) stays in the consumer bundle.

Directions (not a decided fix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions