Skip to content

fix(codec): consumer-onboarding hardening for 0.1.0 first publish#44

Merged
ignromanov merged 7 commits into
mainfrom
fix/codec-consumer-onboarding
Jun 4, 2026
Merged

fix(codec): consumer-onboarding hardening for 0.1.0 first publish#44
ignromanov merged 7 commits into
mainfrom
fix/codec-consumer-onboarding

Conversation

@ignromanov
Copy link
Copy Markdown
Contributor

Consumer-onboarding hardening for the 0.1.0 first publish

Deep publish-readiness audit (4 parallel static audits + an out-of-workspace tarball-install simulation) surfaced consumer-experience gaps that would have shipped as paper-cuts in the very first @void-layer 0.1.0. None were publish-blockers (the release.yml pipeline builds fresh and was already GO), but each degrades the first npm install experience. This batch fixes all of them.

Findings fixed

# Finding Fix
F0 import '@void-layer/networks' (root barrel) could pull viem via a stale local distERR_MODULE_NOT_FOUND without viem. (Build-artifact staleness only; CI always builds fresh.) Verified root barrel is clean post-#40; viem reachable only via ./wagmi subpath
F1 @void-layer/types was a devDependency of codec, but the shipped .d.ts imports it → solo npm i @void-layer/codec left TS consumers without the Invoice type promoted to dependencies (workspace:^^0.1.0)
F7 decodeInvoiceCanonical returned any in the bundler entry .d.ts (only the node entry was typed) applied the typed cast in src/index.ts (types-only, no byte change)
F8 wire internals (decompressBounded, encodeWire, decodeWire) reachable from the public surface confirmed not re-exported from package entry
F5 networks @void-layer/types was workspace:* (publishes as exact pin) workspace:^
F3 sideEffects missing → bundlers can't tree-shake codec ["*.wasm","pkg/**","pkg-node/**"]; networks false
F4 codec engines.node: ">=24" excluded Node 20/22 LTS (no Node-24-only API used) >=20
Ft types & networks emitted *.test.* into dist/ → shipped to consumers excluded **/*.test.ts from build tsconfig (match codec)
D5 stale CodecError::PrecisionLoss in test comment + describe() label InvalidAmount

Deferred: F6 (typed CodecError JS surface) → #43 (additive/non-breaking, 0.1.x).

Verification

  • pnpm -r build · pnpm -r lint · 455 tests · tsc --noEmit ×3 — all green; coverage codec 98%+, networks 100%
  • Empirical consumer re-check (out-of-workspace tarball install, no viem): root import no-crash · golden-vector byte-identity · tsc consumer with codec-only install — passed (Atlas + independent pack)
  • Golden-vector / byte-identity suite green (changes are packaging/types, no encoding touched)

Follow-ups (P2, non-blocking)

  • prepack/prepare build hook (local-pack footgun; CI publish unaffected)
  • align local wasm-pack 0.13.1 → CI pin 0.14.0 (bytes identical; cosmetic)

Both packages were emitting *.test.js / *.test.d.ts triples into dist/,
which would ship in the published tarball. Match codec's existing pattern:
include src/**/*.ts + exclude src/**/*.test.ts.

Also aligns include glob from `src/**/*` (networks) to `src/**/*.ts` —
the broader glob was causing exclude to be ignored by tsc.

Fixes: Ft
… lower engines floor

- F1: Move @void-layer/types from devDependencies to dependencies so TS
  consumers installing only @void-layer/codec get the type auto-installed
  (dist/index.d.ts imports Invoice from @void-layer/types).
- F3: Add sideEffects field — wasm init files are side-effectful; JS/TS
  modules are tree-shakeable. Prevents bundlers from dropping wasm init.
- F4: Lower engines.node from >=24 to >=20 to cover Node 20/22/24 LTS.
  Build confirmed green with current toolchain (wasm-pack 0.13.1).
…cts: false

- F5: Change @void-layer/types from workspace:* (publishes as exact 0.1.0
  pin) to workspace:^ (publishes as ^0.1.0) for patch-version flexibility.
- F3: Add sideEffects: false — pure data/functions package, safe for
  tree-shaking by bundlers.
The bundler entry (src/index.ts) was re-exporting raw wasm bindings whose
generated .d.ts types were `any`. Apply the same typed-cast pattern used
in index.node.ts: import * as _wasmPkg, cast to a typed surface with
Invoice return types, then re-export named consts.

Runtime behaviour is unchanged — same WASM functions, same bytes.
Bundler consumers now get Invoice / Uint8Array return types in their
IDE and tsc --noEmit checks instead of `any`.

Verified: tsc --noEmit on fresh consumer project exits 0 with strict mode.
Comment referenced CodecError::PrecisionLoss; the actual variant is
CodecError::InvalidAmount. Comment-only change, no logic affected.
Reflects @void-layer/types moving from devDependencies to dependencies
in @void-layer/codec (F1 fix).
@ignromanov ignromanov merged commit b878ddb into main Jun 4, 2026
7 checks passed
@ignromanov ignromanov deleted the fix/codec-consumer-onboarding branch June 4, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant