refactor(#86): pure-logica extract naar src/game/ + build-stap #95
Labels
No labels
blocked
bug
design
documentation
duplicate
enhancement
future
good first issue
help wanted
invalid
question
refactoring
tracker
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jelmer/topoquiz#95
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #86 (code-audit scope 1). Zie AUDIT.md §1.3 + §4.
Context
~280 LOC pure logica in `index.html` (haversine, levenshtein, dateSeedG, seededShuffle, dailyPool, BonusPool, fuzzy-matching, smoothing helpers) is vandaag al 1:1 getest in `test.js` maar blijft in de monoliet staan. Verhuizen naar `src/game/*.js` maakt:
Vereist een bundle-stap (esbuild of native `
Bundler-keuze: native ESM (geen build-stap)
Beslist na afweging native ESM / esbuild / Vite in v2.24.1-sessie.
Rationale
bundle.hash.js-hit./src/game/daily.js:L, geen sourcemap-indirectie.cities.jsis al een losse top-level file dieindex.htmllaadt;src/game/*.jsis hetzelfde patroon.Scope-impact
src/game/{date,fuzzy,shuffle,daily,smooth,geo}.js— ESM-exports (named).index.html: één<script type="module">metimport { dailyPool } from '/src/game/daily.js'etc. Behoud cities.js-globals (aparte migratie).test.js→ ESM ("type":"module"in package.json of rename naartest.mjs). Importeert direct uitsrc/game/— geen spiegel-definities meer..github/workflows/e2e.ymlrsync-allowlist:--include='src/***'toevoegen.sw.js:/src/game/*.jsopnemen inASSETSzodat PWA offline blijft werken.Escape-hatch
Als de module-count ooit > ~15 wordt, of TypeScript / een framework intreedt: esbuild-toevoegen bovenop deze structuur is 1 dag werk, geen re-write. Je gooit niks weg door nu native ESM te kiezen.
Done. Pure-logica-extract is gemerged in v2.25.x —
src/game/text.js,src/game/geo.js,src/game/click.js,src/game/daily.js,src/game/shapes.js,src/game/smooth.js.test.mjsimporteert nu direct uit die modules (geen spiegel-code meer). Bundle-stap bleek niet nodig — native ES modules via<script type="module">werkt zowel op CF als Uberspace (sw.js cachet de losse files). Index.html gekrompen met ~280 LOC.