Skip to content

perf(core): claw back ~0.85 kB gzip vs v0 #1759

Description

@yamcodes

Context

@arkenv/core@1.0.0-alpha.9 is ~3.1 kB gzip / ~7.5 kB min vs v0 arkenv@0.12.3 ~2.3 kB gzip / ~5.7 kB min (Bundlephobia; arktype peer excluded). size-limit was raised 2.2 → 2.9 kB.

This is the v1 @arkenv/core package (v1 branch), not the old v0 arkenv/core ~441 B ArkEnvError stub.

The delta is always-on in the default import arkenv path: issue objects, pretty-print, secret redaction, { safe: true }, and CLI schema-capture. Not source maps, dual CJS/ESM, or arktype.

Keep (out of scope)

Realistic target after the cuts below: ~2.5 kB gzip. Hitting 2.0 would mean dropping redaction or EnvIssue — don't.

Subtasks

  • Pull CLI schema-capture (Symbol.for("arkenv.schemaCapture.v1"), feat: CLI schema loader — safely import a user's env.ts and expose its declared keys #1622) out of the default arkenv() path. CLI-only entry or subpath so production imports don't pay for it (~330 B min plus capture branches).
  • Stop re-exporting formatIssues / getSchemaKeys from the main @arkenv/core barrel (move to a subpath, e.g. @arkenv/core/issues). Set "sideEffects": false on the package (currently unset; Bundlephobia reports hasSideEffects: true). size-limit and Bundlephobia import "*", so extra barrel exports inflate the published number; real apps also cannot tree-shake today.
  • Split { safe: true } (safeExecute, buildEnvIssue, (v1) Unify error normalization and formatting #1157) to an opt-in subpath (@arkenv/core/safe or named tryArkenv) so the throw path does not include result-object machinery.
  • Re-measure: size-limit + Bundlephobia (or esbuild minify+gzip of dist/index.mjs, ignore arktype). Confirm ~2.5 kB gzip and that redaction / coercion / keywords still work on the default export.

Notes

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

    arkenvChanges to the `arkenv` npm package.enhancementNew feature or improvementready for agentFully specified, ready for immediate implementationrefactorA change to the codebase that's neither a bug fix nor added functionality

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions