From 87cfecf8a802e22462c5326e74a9ca6e29e6aac9 Mon Sep 17 00:00:00 2001 From: "K. O. A." Date: Sun, 5 Jul 2026 21:48:38 -0400 Subject: [PATCH 1/2] best-practices: add "Organizing client code across files" section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add guidance for splitting a plugin's client JS instead of one monolithic screen.js, ground-truthed against how the Host loads and serves plugin JS. Rules (27-29): - Prefer bundling to one screen.js if you have build tooling — the Host loads one script, sidestepping the runtime gotchas. (No bundler ships in-tree; it's your own build step.) - screen.js runs as a CLASSIC script: no top-level import/export, no import.meta. Split files share state via window (namespaced by id), not ES exports. - Serve extra files from assets/ (the plugin root is NOT servable — a file there 404s; under assets/ the Host serves it traversal-guarded with a JS MIME), or a routes.py-served dir. Reference by ABSOLUTE /api/plugins//assets/... URLs — a relative import() from a classic script resolves against the document, not the script. Dynamic import() of an ES module from assets/ works; classic