Repository navigation
Replies: 1 comment
|
Thank you for the proposal. The page scripts are now bundled with esbuild into content-hashed chunks in v0.11.8. The recording list loads 28 script files instead of 101, and about 40% fewer script bytes. A size budget check in CI is not included. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
templates/index.htmlloadsstatic/js/app.modular.jsas a module attemplates/index.html:254, and its static imports atstatic/js/app.modular.js:4-60plus transitive imports resolve to 85 files understatic/js/, each fetched as a separate request; with the 15 classic scripts the document declares, the list route pulls 100 script files and 7 stylesheets.There is no bundler in the tree, so the browser downloads, parses and links every module of the graph individually, including the nine ASR editor modules of
static/js/modules/asr-editor/, which load before the editor is ever opened, and the 95.5 kBstatic/js/modules/composables/audio.jsand 99.7 kBstatic/js/modules/composables/ui.jscomposables. The cost is 1 421.7 kB raw / 371.1 kB gzip across the 85 module files on every cold list load, and/inquirealready avoids this by loading 12 modules throughimport()while the shell does not.Affected Version
v0.11.7
Requested Feature
Introduce a build step that emits one or two versioned bundles for the app shell and keeps interaction-only blocks as separate lazy chunks, starting with the ASR editor modules,
audio.jsandui.js. The shell should load a small entry point instead ofapp.modular.js, and the lazy chunks should be fetched only when the feature that needs them is first used.The build must produce cacheable, versioned filenames so a reload can reuse the bundles without revalidation, and the vitest module tests under
static/js/**/*.test.jsmust keep passing against the source modules.Proposed Implementation
scripts/build_css.shthat runs a JavaScript bundler overstatic/js/app.modular.jsand writes versioned bundles understatic/js/dist/(or a similar build output directory), with a source map for debugging. Mirror the CSS build's pinned-tool and checksum approach so Docker and local builds stay reproducible.static/js/modules/asr-editor/pane.js,timeline.js,timeline-geometry.js,timeline-peaks.js,virtual-list.js,trim.js) behind an async component factory registered instatic/js/app.modular.js:5368-5370, and defer themodel.js,draft.jsandhelpers.jsimports atstatic/js/modules/composables/asr-editor.js:12-16, so the whole nine-file block is split into a chunk fetched whenopenAsrEditorModalruns.static/js/modules/composables/audio.jsandstatic/js/modules/composables/ui.jsinto chunks loaded on the first interaction that needs them, keeping the theme, upload and player handlers the list route uses in the shell bundle.<script type="module" src=".../app.modular.js">tag attemplates/index.html:254with the built entry point, and keep the classic scripts that the page still needs as they are.Cache-Control: public, max-age=31536000, immutableusing content-hashed filenames, so a reload does not revalidate them.static/js/modules/...directly, and the bundler consumes the same files, so no test path changes.Expected Behavior
audio.jsandui.jsleave the eager graph while their list-route theme, upload and player handlers stay available.static/js/**/*.test.jscontinues to import and test the source modules unchanged, and a fresh worktree can still runnpx vitest runafternpm install.Root Cause Analysis
The shell has no bundling step:
templates/index.html:254loadsstatic/js/app.modular.jsas an ES module, and its static imports atstatic/js/app.modular.js:4-60plus transitive imports pull in 85 files understatic/js/. The browser fetches each file individually because nothing in the tree concatenates or splits them;scripts/build_css.shonly compiles CSS, andpackage.jsondeclares no bundler dependency.The ASR editor components are registered unconditionally at
static/js/app.modular.js:5368-5370, which drags six of the ninestatic/js/modules/asr-editor/files (pane.js,timeline.js,timeline-geometry.js,timeline-peaks.js,virtual-list.js,trim.js) into the eager graph, and the composable atstatic/js/modules/composables/asr-editor.js:12-16addsmodel.js,draft.jsandhelpers.js, even though they are only used afteropenAsrEditorModalatstatic/js/modules/composables/asr-editor.js:157. The same applies toaudio.jsandui.js, which are large composables with list-route handlers for theme, upload and playback, so they are candidates for a split rather than full deferral.The
/inquireroute avoids this by loading 12 modules throughimport()intemplates/inquire.html:448-456, which is why it is not part of the same 100-file burst. The vitest suite imports the source modules directly, so any bundling change must keep those entry points intact rather than rewriting the module graph in a way the tests cannot follow.Additional Context
Measured on the list route at v0.11.7: 1 421.7 kB raw / 371.1 kB gzip across the 85 module files, with 100 script files and 7 stylesheets in total including 15 classic scripts. The ASR editor block is 227.1 kB raw / 57.7 kB gzip across 9 files, and EasyMDE is a separate 340.4 kB raw / 109.8 kB gzip interaction-only asset loaded from the head at
templates/index.html:65andtemplates/index.html:92.The CSS build at
scripts/build_css.shis the existing model for a pinned, checksum-verified, offline build tool, and the Dockercss-stageinDockerfileshows where a second build stage should be added. The service worker atstatic/sw.jscaches only/static/*responses, so hashed bundle filenames will be picked up automatically once they are served from that path.All reactions