Skip to content

perf(core): split clients into tree-shakable modules and cut published bytes - #384

Open
cameronapak wants to merge 7 commits into
mainfrom
cp/core-split
Open

perf(core): split clients into tree-shakable modules and cut published bytes#384
cameronapak wants to merge 7 commits into
mainfrom
cp/core-split

Conversation

@cameronapak

@cameronapak cameronapak commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Stack 1/3 — base of #382.

What

  • Core clients split into bible-* / languages-* modules so partners importing one symbol stop pulling the whole client graph
  • Zod-mini schemas, minified browser CSS, shared filtered paged-list helper (fetchFilteredCollection)
  • Version-stamp check updated for the new dist layout

Why

Heart goal of the branch: smaller import size for partners, backwards compatible.

Verification

  • pnpm build --force, pnpm typecheck, pnpm test (432 core tests), pnpm check:tree-shaking all pass on this branch alone — with main's hooks and ui, which is the back-compat proof
  • No public API change; lockfile unchanged

Merge first of the stack (then #385, then #382).

— Cursor, an AI agent sent on behalf of Cam

Greptile Summary

The PR splits core clients into narrower tree-shakable modules, migrates validation to Zod Mini, and changes generated package output to reduce published bytes.

  • Adds modular Bible and language client entry points while preserving facade clients.
  • Moves browser CSS publication to minified dist/styles artifacts and restores the public theme-token set.
  • Extracts shared filtered collection and version-filter state behavior.
  • Updates build, declaration, and SDK version-stamp handling for the new distribution layout.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains from the previous review threads.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/core/src/bible.ts Refactors the existing BibleClient into a compatibility facade over focused tree-shakable modules without an accepted blocking issue.
packages/core/src/languages.ts Refactors LanguagesClient into a facade while moving its options contract to a schema-derived type.
packages/core/src/version-filters.ts Centralizes filtered pagination behavior shared by version and language collection clients.
packages/core/src/styles/theme.css Separates preflight CSS while retaining the palette, chart, sidebar, semantic, and dark-theme token contract.
packages/core/package.json Publishes generated CSS and excludes implementation-only split-module artifacts from the package.
packages/core/tsup.config.ts Defines the split JavaScript entry graph and distribution behavior used for tree shaking.
.changeset/ype-5528-core-split.md Records the core package release and explicitly documents the accepted Zod Mini error-identity behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Consumer[Consumer import] --> Entry[Core package entry]
  Entry --> Api[ApiClient module]
  Entry --> Bible[Bible facade]
  Entry --> Languages[Languages facade]
  Bible --> Chapter[bible-chapter]
  Bible --> Reads[bible-reads]
  Bible --> Versions[bible-versions]
  Bible --> Passage[bible-passage]
  Languages --> Language[languages-language]
  Languages --> List[languages-list]
  Versions --> Filter[Shared filtered collection]
  List --> Filter
  Build[Core build] --> JS[Tree-shakable JS entries]
  Build --> CSS[Minified dist/styles]
  Build --> Types[TypeScript declarations]
Loading

Reviews (7): Last reviewed commit: "fix(core): drop ZodError wrap and docume..." | Re-trigger Greptile

Context used (4)

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4a4d74e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch
@youversion/platform-react-ui Patch
vite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/core/src/styles/theme.css Outdated
Comment thread packages/core/src/languages-list.ts Outdated
Comment thread packages/core/package.json
Comment thread packages/core/src/styles/theme.css
Comment thread .changeset/ype-5528-core-split.md
Comment thread scripts/check-sdk-version-stamp.mjs
Comment thread packages/core/package.json Outdated
Comment thread packages/core/src/schemas/language.ts Outdated

@cameronapak cameronapak left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

No Jira. Spec is the Cam-selected review-comment fixes (Conductor re-review).

Summary

  • Standards must-fix: 0
  • Spec must-fix: 0
  • Worst: none blocking (ZodError wrap covers instanceof; classic helpers like format()/flatten() are still absent)
For Agents

CI: pass (Lint Commit Messages may still be settling)
Greptile: pass / partnered — old ZodError P1 addressed for instanceof; residual method-surface caveat noted below
Event: COMMENT (Cam-authored — no self-APPROVE)
HEAD: 4703196
Cam fixes verified:

  1. ui in PACKAGE_DIRS — pass
  2. page_size="*" exact Error text — pass
  3. dev.mjs CSS watch → dist/styles — pass
  4. changeset patch + parsePublic Mini wrap — pass
    Resolve outdated Austin/Cursor threads for 1–3 when posting.

By Code Reviewer bot, sent on behalf of Cam.

Comment thread packages/core/src/parse-public.ts Outdated

@cameronapak cameronapak left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

No Jira. Spec is the Cam override (drop parsePublic wrap; document Mini $ZodError).

Summary

  • Standards must-fix: 0
  • Spec must-fix: 0
  • Worst: none blocking (changeset catch snippet should prefer z.core.$ZodError)
For Agents

CI: pass
Greptile: pass
Event: COMMENT (Cam-authored — no self-APPROVE)
HEAD: 9ff6bbd
Verified: parsePublic gone; .parse(); changeset patch + Mini note; ui stamp; page_size Exact Error; CSS watch.

By Code Reviewer bot, sent on behalf of Cam.

Comment thread .changeset/ype-5528-core-split.md
cameronapak and others added 7 commits September 9, 2026 11:50
…d bytes

Stack 1/3 of #382. Core-only changes: module split into bible-*/languages-*
files, zod-mini schemas, minified browser CSS, shared filtered paged-list
helper, and the version-stamp check update.
… refine

- Move client-module input schemas (version/book/chapter/verse ids, language
  id, organization id, highlight passage/color) into schemas/ so schemas stay
  the single source of truth; import schema files directly, not the barrel,
  to keep tree-shakable entries narrow
- Restore the page_size="*" 1-3 fields refine on GetLanguagesOptionsSchema
  (dropped in the module split, replaced by an unreachable plain-Error check)
- Dedupe BCP-47 regex and hex-color schema; type fetchFilteredCollection params
- Document zod-mini $ZodError behavior note in the changeset; refresh core
  AGENTS.md STRUCTURE
… identity

Keep the changeset as patch. Restore the UI version-stamp entry so UI
prepublishOnly still works, throw the prior page_size="*" Error message,
watch core CSS into dist/styles during pnpm dev, and wrap Mini $ZodError
at the public client boundary so instanceof ZodError still matches.
Keep zod Mini as the public validation identity. Remove parsePublic and
restore direct schema.parse(). Changeset stays patch and notes that
schema failures throw $ZodError, not classic ZodError. page_size="*",
UI stamp, and CSS watch stay as-is.
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.

3 participants