Add lightweight entry points and dynamic data loading #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces two new entry points to the
@shafeh/tanachpackage to support size-constrained environments (edge functions, serverless, etc.):/preferred– A lightweight module (~50 KB) for preferred verse lookups without importing the full Tanach data/dynamic– An async module that fetches per-book JSON files on-demand instead of bundling the entire 6+ MB datasetKey Changes
package.json: Added exports for./preferredand./dynamicalongside the main entry pointvite.config.tsto build three separate entry points with proper file naming (index.cjs/index.js,preferred.cjs/preferred.js,dynamic.cjs/dynamic.js)scripts/generate-preferred-with-text.ts– Generatessrc/preferred-verses-data.tswith 457 preferred verses and their embedded textscripts/generate-book-data.ts– Splits the full Tanach data into 24 per-book JSON files (5–215 KB each) for dynamic loadingsrc/preferred.ts– Synchronous preferred verse lookups with embedded text (no data import needed)src/dynamic.ts– Async data functions that fetch books on-demand from a configurable base URLsrc/preferred.test.ts– Tests for the lightweight preferred verses modulesrc/dynamic.test.ts– Tests for dynamic loading with mocked fetchsrc/preferred-verses.tsto normalize final-form Hebrew letters (ם→מ, ך→כ, etc.) in lookup keys for consistencyImplementation Details
preferredVersesWithTextarray is auto-generated and includes full verse text, Hebrew/English book names, and metadata—enabling zero-dependency preferred verse lookupsconfigure()function to set the base URL for book JSON files. All data functions are async and fetch books in parallelnormalizeHebrewLetter,extractHebrewLetters,getAllLetterForms) are available in both/preferredand/dynamicmodulesSize Benefits
https://claude.ai/code/session_01XDYfksN1mSwXwrduTMtrtQ