Skip to content

Feature Request: import only Effect's schema modules #232

Open

Description

@FluteBlade

json-schema.js imports effect whole whenever it is installed, at the top level, though the converter uses only Schema and JSONSchema. Importing effect/Schema, plus effect/JSONSchema on Effect 3, would load and bundle much less. Both exist from 3.14.2, the lowest version the peer range allows. Effect 4 has only effect/Schema, which is all the conversion in #231 needs. We measured each import on Node 26, and bundled it with rolldown, unminified:

Load, effect Load, the modules Bundled, effect Bundled, the modules
Effect 4.0.5 190 ms 120 ms 4.4 MB 1.0 MB
Effect 3.20.0 250 ms 170 ms 3.4 MB 0.8 MB

Every command pays the load time, --help included, and a bundled CLI, as ours is, carries the whole package.

Going further, trpc-cli could import no schema library at all. It already falls back to a schema's own ~standard.jsonSchema, and taking the other converters from the user, as oRPC does, would leave nothing to import. CLIs that don't use Effect would save the remaining 120 ms and 1 MB. Users of Valibot, Effect, Zod 3 and zod/mini would pass a converter to createCli, which the help text could suggest as it now suggests installing @valibot/to-json-schema, so it would be a small change for a major release.

Module mode could follow the same rule. Node loads it only when it is used, but since createCli chooses it by its arguments, bundlers include it anyway: with rolldown, a CLI built on a router bundles 612 KB of trpc-cli, 453 KB of it module mode with TypeBox. An entry point of its own, as TypeBox schemas have in trpc-cli/typebox, would leave it out, and give createCli one signature rather than one whose results turn async by its arguments.

Activity

  1. pullfrog commented on Oct 24, 2026

    @pullfrog
  2. FluteBlade commented on Oct 24, 2026

    @FluteBlade
    Author

    The same applies to import('zod/v4/core'), which brings all 64 of Zod's locales, about 270 KB, into a bundle that only converts a schema: Rolldown keeps the whole namespace of a dynamic import, even when it is destructured where it is made. With zod 4.6.7, the namespace bundles to 577 KB, a named import of toJSONSchema to 46 KB with no locales. Converters passed in, as proposed above, would avoid both.

  3. mmkal commented on Oct 27, 2026

    @mmkal
    Owner

    Good findings. Yes, some of the json schema stuff predates standard-json-schema. Last I checked there were some niceties lost by fully switching over, but at this point we could probably safely just accept the standard more fully and simplify/optimise the loading. I haven't looked at this PR yet but I'll have a look this week.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions