PURPOSE

Auto-loads every VFX component JSON file from the components data directory and exposes them as a sorted seed list for the weapon workbench library.

OWNS

  • SEED_COMPONENTS — the exported readonly array of component objects, sorted by id.
  • sortById — internal comparator that compares two components by their string id field.
  • modules — internal eager glob result keyed by file path.

READS FROM

  • ../../data/vfx/components/*.component.json — every JSON file matching this glob, loaded via import.meta.glob with eager: true and import: 'default'.

PUSHES TO

  • Consumers in the weapon-workbench screen that import SEED_COMPONENTS to populate the component library.

DOES NOT

  • Does not validate, parse, or normalize the JSON payloads — values are cast through unknown to readonly any[].
  • Does not watch the filesystem at runtime; new files appear only after a dev-server reload.
  • Does not filter, deduplicate, or merge components.
  • Does not handle errors from missing or malformed JSON files.

Signals

None. The module performs its work at import time and exports a single static constant.

Entry points

  • Module side effect: Vite resolves the glob at build/dev-load time, eagerly importing each matching JSON file’s default export.
  • SEED_COMPONENTS named export.

Pattern notes

  • Uses Vite’s import.meta.glob with eager: true so the component list is synchronously available at module evaluation rather than as a set of dynamic import promises.
  • The import: 'default' option pulls the default export of each JSON module directly, avoiding a wrapper object.
  • Sort is stable on id via String(a.id ?? '').localeCompare(...), tolerating components whose id is missing or non-string.
  • Type discipline is deliberately loose (Record<string, unknown> glob, double cast through unknown to readonly any[]) to keep this fixture file decoupled from component schema definitions elsewhere.
  • Convention-driven: dropping a new *.component.json file into the components directory is the entire authoring step; no registration code change is needed.