refactor: share LMS fail-loud error across selectors, cache JS parses#93
Merged
Conversation
Extract LMSAdapterError + per-standard labels + missingApiError into an adapter-free lms-error.ts. The runtime createAdapter and the build-time generated single-adapter modules now throw the same rich message instead of two hand-maintained copies that had already drifted; the generated module imports from lms-error.js (no adapter deps) instead of index.js, keeping the four unused adapters out of LMS bundles. Collapse the plugin's four near-identical adapter-source switch cases into one table-driven generator. Cache JS-module acorn parses in ast.ts (mirroring the existing .svelte rootCache) so readCourseConfig's ~9 call sites per build don't re-parse course.config.js each time. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two cleanups from a codebase review.
createAdapterand the plugin's generated single-adapter modules each carried their own fail-loud message, and they'd drifted (the generated ones were terser and pulled all four unused adapters in viaindex.js). ExtractedLMSAdapterError+ labels +missingApiErrorinto an adapter-freelms-error.tsboth now share, and collapsed the plugin's four near-identical adapter-sourceswitchcases into one table-driven generator.ast.ts(mirroring the existing.svelterootCache) soreadCourseConfig's ~9 call sites per build don't re-parsecourse.config.jseach time.Behavior change: production LMS builds now throw the runtime's fuller error text on a missing API. No test asserted the old wording.
Verification
pnpm check: clean ·pnpm --filter tessera-learn test: 944 passed ·pnpm build: ok