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:
VB[...]; the 120 files that load src/load.js are unchanged and pass.loadModules (VB-375) loads the mixed set: Node needs to see .js as ES modules (to verify: a "type": "module" in src/package.json, or .mjs, and require() of an ES module, which Node 22.23 allowed for .ts in a scratch directory on 12 November), or loads the esbuild bundle; the choice is in the task file.tools/writes.js lists all start at sim/relations, sim/help, sim/expansion, sim/farmclaims or sim/commands).node tools/same.js --base REF prints same; tests/counters.json and index.html’s behaviour unchanged. Lines changed (git diff –stat) are in the task file.tests/dependencies.js still passes unchanged (VB-379 changes it).docs/typescript-plan.md, where this task is P4): waits for Kim’s answers to QUESTIONS.md, “VB-055: the move to TypeScript” (the formatter, the bundler, the hook, the width measures, when, the page and the tests, strict), which may change its criteria; the three rules common to these tasks are at the top of the plan.src/ (a window: VB-376 to VB-378 together).
Notes:QUESTION_ARCHIVE.md, VB-055, answer 5). This task opens the first window (VB-376 to VB-378, no other task editing src/ between them), after slice 3’s wrap-up, hence the wait for VB-108; VB-380 is the second window, right after.