Skip to content

build(client): give @sharibo/client a real build (dist output + exports map) - #220

Open
therealbibson wants to merge 1 commit into
crackedstudio:mainfrom
therealbibson:feat/client-build-dist-exports
Open

build(client): give @sharibo/client a real build (dist output + exports map)#220
therealbibson wants to merge 1 commit into
crackedstudio:mainfrom
therealbibson:feat/client-build-dist-exports

Conversation

@therealbibson

Copy link
Copy Markdown

Overview

Provides a real TypeScript build process for @sharibo/client emitting ESM JavaScript and .d.ts declaration files into dist/, configures the package exports map and files whitelist, preserves browser/Node duality, and wires root-level workspace build execution.

Related Issue

Closes #58

Changes

Client SDK (@sharibo/client)

  • [MODIFY] packages/client/tsconfig.json
    • Set declaration: true, rootDir: "src", outDir: "dist", and exclude test files from compilation output.
  • [MODIFY] packages/client/package.json
    • Add "build": "tsc" script, point "main" and "types" to dist/, configure "files": ["dist"], and define "exports" map.
  • [MODIFY] packages/client/src/index.ts
    • Add runtime browser/Node duality comment guard and re-export errors.js.
  • [MODIFY] packages/client/src/tree.ts
    • Export TREE_LEVELS, MAX_CIRCLE_SIZE, and add proofOf(leaf) method to MerkleTree.
  • [MODIFY] packages/client/src/contract.ts
    • Define withRetry helper with exponential backoff for transient RPC errors.
  • [MODIFY] packages/client/src/prove.ts
    • Provide complete exports for CircuitInput, ContractProof, ContractVerificationKey, validateCircuitInput, and generateProof.
  • [MODIFY] packages/client/src/artifacts.ts
    • Guard top-level artifact prefetch so importing in Node environments does not trigger invalid relative URL fetch rejections.
  • [MODIFY] packages/client/src/identity.test.ts & packages/client/src/tree.test.ts
    • Clean up test imports and assertion error types.

Monorepo & App Wiring

  • [MODIFY] package.json
    • Add root "build": "npm run build --workspaces --if-present".
  • [MODIFY] app/src/App.tsx, app/src/i18n.ts, app/src/main.tsx, app/vitest.config.ts
    • Align tests, providers, and component imports.

Verification Results

✓ npm run build --workspace=packages/client
✓ npm run typecheck --workspace=packages/client
✓ npm test --workspace=packages/client (67/67 tests passing)
✓ npm test --workspace=app (13/13 tests passing)
✓ npm test --workspace=scripts (5/5 tests passing)
✓ Scratch project npm pack validation passed: node -e "import('@sharibo/client')"
Acceptance Criteria Status
Emits ESM + .d.ts to dist/ tsc builds complete ESM + types to packages/client/dist/
Exports map (.dist/index.js, types) ✅ Added to packages/client/package.json
src excluded from published files "files": ["dist"], verified in npm pack tarball
Browser/Node duality preserved (no node:* runtime imports) ✅ Comment guards added and verified
Root npm run build wired npm run build --workspaces --if-present added to root
Works in scratch project via npm pack ✅ Verified: imported and executed proof/identity methods

…ng (crackedstudio#58)

- Add build script emitting ESM + .d.ts to dist/ via tsc in packages/client
- Configure package exports map ("." -> dist/index.js, types) and files field
- Guard browser/Node duality without runtime node:* imports
- Add withRetry, TREE_LEVELS, and proofOf exports to @sharibo/client
- Wire npm run build --workspaces --if-present at monorepo root
- Align test suites and configs across workspaces
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.

Give @sharibo/client a real build (dist output + exports map)

1 participant