Skip to content

FormState.modules is a generic Map that has only ever held one key #668

Description

@ozzyfromspace

FormState.modules is a Map<string, unknown> described as a cache "for per-state modules, chiefly history". In practice it holds exactly one key, 'history', written at use-abstract-form.ts:249 and read at use-abstract-form.ts:292 and use-form-context.ts:118. Nothing else has ever registered a module.

Collapsing it to a dedicated optional field on the state measures 38 B gz eager, with undo/redo fully intact.

Small, self-contained, and it makes the shape honest: a one-key generic registry reads as an extension point that does not exist.

Not included here, deliberately. Making form.history undefined on an unconfigured form measures a further 58 B, and it is a worse trade. build-form-api.ts:89-96 argues the current shape correctly: one instance serves every such form, and a template reads form.history.canUndo unconditionally. Turning a total API into a partial one means a template that forgets ?. throws during SSR render, which is a 500 rather than a console warning. 58 B does not buy that failure mode.


Found in the 2026-09-18 feature audit (main@b4a64ef9, eager baseline 33,204 B gz). Every byte figure is a measured ablation, not an estimate.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PnAVwFjpvKQNppAMkSvoiH

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions