Skip to content

Refactor preloaded contexts to per-context static JSON assets #627

@dahlia

Description

@dahlia

Summary

This issue is a follow-up from PR #622, where #622 (comment) suggested moving preloaded context definitions out of TypeScript implementation code, and the change was noted as a good candidate for a separate task.

Goal

Refactor context data loading so each context is stored as an individual static JSON asset instead of being bundled together in one large in-code definition, while keeping runtime behavior and public API behavior stable.

Proposed approach

Create one JSON file per context under packages/vocab-runtime/src/contexts/ and load them through JSON imports in packages/vocab-runtime/src/contexts.ts using the native import ... with { type: "json" }; syntax, then normalize them into the existing internal runtime structure.

Data layout

Store context definitions separately, for example packages/vocab-runtime/src/contexts/activitystreams.json and packages/vocab-runtime/src/contexts/gotosocial.json, and build the registry/index from these files so each context can be updated independently.

Why this helps

A per-context file layout reduces merge conflicts, narrows review scope to only the changed context, and makes future updates and regeneration easier because data-only modifications stay isolated from runtime code.

Acceptance criteria

The refactor is complete when the effective behavior of context lookup and rendering is unchanged, tests pass across Deno/Node/Bun, exported API contracts remain unchanged, and updating a single context does not require editing unrelated context data in shared code.

References

PR discussion: #622 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions