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 byid.sortById— internal comparator that compares two components by their stringidfield.modules— internal eager glob result keyed by file path.
READS FROM
../../data/vfx/components/*.component.json— every JSON file matching this glob, loaded viaimport.meta.globwitheager: trueandimport: 'default'.
PUSHES TO
- Consumers in the weapon-workbench screen that import
SEED_COMPONENTSto populate the component library.
DOES NOT
- Does not validate, parse, or normalize the JSON payloads — values are cast through
unknowntoreadonly 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_COMPONENTSnamed export.
Pattern notes
- Uses Vite’s
import.meta.globwitheager: trueso 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
idviaString(a.id ?? '').localeCompare(...), tolerating components whoseidis missing or non-string. - Type discipline is deliberately loose (
Record<string, unknown>glob, double cast throughunknowntoreadonly any[]) to keep this fixture file decoupled from component schema definitions elsewhere. - Convention-driven: dropping a new
*.component.jsonfile into the components directory is the entire authoring step; no registration code change is needed.