Skip to content

Refactor preloaded contexts into static JSON assets#641

Merged
dahlia merged 1 commit intofedify-dev:mainfrom
dahlia:preloaded-contexts
Mar 23, 2026
Merged

Refactor preloaded contexts into static JSON assets#641
dahlia merged 1 commit intofedify-dev:mainfrom
dahlia:preloaded-contexts

Conversation

@dahlia
Copy link
Member

@dahlia dahlia commented Mar 23, 2026

Summary

This PR refactors the preloaded JSON-LD contexts in @fedify/vocab-runtime so that each context is stored as its own static JSON asset instead of being embedded together in one large TypeScript object.

Details

Each preloaded context now lives under packages/vocab-runtime/src/contexts/, and packages/vocab-runtime/src/contexts.ts rebuilds the existing preloadedContexts registry through static JSON imports while preserving the same URL keys, exported API shape, and runtime behavior.

Rationale

This keeps data-only context updates isolated from runtime code, reduces merge conflicts when multiple contexts change independently, and makes context changes easier to review because unrelated definitions no longer live in the same source block.

Testing

I verified the change with deno task -f @fedify/vocab-runtime test, pnpm --filter @fedify/vocab-runtime test, deno test --check --allow-all packages/fedify/src/utils/kv-cache.test.ts, node --test utils/kv-cache.test.js from packages/fedify/dist, and bun test utils/kv-cache.test.js --timeout 60000 from packages/fedify/dist.

Notes

This is an internal refactor with no user-visible behavior change, so CHANGES.md was intentionally not updated.

Related issue

Fixes #627

Refactor @fedify/vocab-runtime's preloaded JSON-LD contexts so
that each context lives in its own static JSON asset under
packages/vocab-runtime/src/contexts/.

Keep the exported preloadedContexts registry and its URL keys
unchanged while replacing the monolithic in-code definition with
static JSON imports.  This makes single-context updates easier to
review and reduces unrelated merge conflicts.

Fixes fedify-dev#627

Co-Authored-By: OpenAI Codex <codex@openai.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant internal refactoring to the @fedify/vocab-runtime package by externalizing JSON-LD contexts into individual static JSON files. This change aims to enhance the organization and maintainability of context definitions, making future updates and code reviews more efficient and less prone to conflicts, all without altering any user-facing behavior.

Highlights

  • Refactoring of JSON-LD Contexts: Preloaded JSON-LD contexts have been refactored from a single large TypeScript object into individual static JSON assets, improving modularity and maintainability.
  • File Organization: Each preloaded context is now stored in its own dedicated JSON file under the packages/vocab-runtime/src/contexts/ directory.
  • API and Runtime Preservation: The existing preloadedContexts registry is rebuilt through static JSON imports, ensuring that the same URL keys, exported API shape, and runtime behavior are preserved.
  • Improved Maintainability and Reviewability: This refactor isolates data-only context updates, reduces the likelihood of merge conflicts when multiple contexts are modified, and makes context changes easier to review by separating unrelated definitions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dahlia dahlia self-assigned this Mar 23, 2026
@dahlia dahlia added component/federation Federation object related component/build Build system and packaging labels Mar 23, 2026
@dahlia dahlia added this to the Fedify 2.1 milestone Mar 23, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively refactors the preloaded JSON-LD contexts into separate static JSON assets, which is a great improvement for code organization and maintainability. The changes are well-structured. I've found one potential issue in the gotosocial.json context file, which appears to be a typo that affects correctness.

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
packages/vocab-runtime/src/contexts.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@2chanhaeng 2chanhaeng left a comment

Choose a reason for hiding this comment

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

Great!

@dahlia dahlia merged commit 1ff2688 into fedify-dev:main Mar 23, 2026
16 checks passed
@dahlia dahlia deleted the preloaded-contexts branch March 23, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/build Build system and packaging component/federation Federation object related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor preloaded contexts to per-context static JSON assets

2 participants