village-builder

VB-376: ES modules, part 1: the first 21 modules of the manifest

Status: blocked Waits for: VB-108 Priority: 3 Size: M Arch: yardstick Phase: implement Design ref: none (code structure). docs/typescript-plan.md (P4); the survey in backlog/VB-055.md. Goal: Turn the first 21 modules of src/manifest.json (vb, the five gen/*, gen, culture, then sim/rules through sim/records), from VB['key'] = (() => { ... return { ... }; })(); into files with import and export. A codemod (tools/esm-codemod.js, kept until VB-378 is done and then deleted) does the common shape: the IIFE’s wrapper and return { ... } go, const { a, b } = VB['x'] becomes import { a, b } from './x.js', export goes before each name of the return list. The body is not re-indented (that is the formatter’s work, in VB-380, so the diff of this task is the head, the imports and the exports of each file, a few hundred lines in all). While some modules are converted and some not, a converted file ends with VB.register('key', ns) (import * as ns from './self.js'; to verify that a module may import itself), and src/vb.js keeps the VB object, so an unconverted module’s VB['key'] and every test still work. Chunk boundaries follow the manifest, so a converted module imports only converted ones. Acceptance criteria: