# Plugin ES-module migration playbook How to move a plugin off a single global-scope `screen.js` IIFE onto a native ES-module graph — **no build step, no framework, no bundler**. This is the mechanism the monolith-killing refactor uses; the host rails for it shipped in R0 (see `.specify/memory/constitution.md` Principle II + the "Module load contract" in Operating Constraints). ## The shape ``` my-plugin/ plugin.json + "scriptType": "module" ← opt in screen.js import './src/main.js'; ← the entire file src/ state.js (0) module state + accessors util/… (1) pure helpers — real-import testable …/… (2..4) model → render/audio/io → input globals.js (5) THE ONLY file that writes window.* main.js (5) boot: wire modules, register screen:changed assets/… worklets / WASM / images (unchanged, served as today) ``` `screen.js` becomes a one-line static `import`. The host injects it as `