Skip to content

feat: defer viewer bundle load and preload after first paint - #10

Merged
mlightcad merged 1 commit into
mainfrom
feat/lazy-viewer-preload
Aug 11, 2026
Merged

mlightcad merged 1 commit into
mainfrom
feat/lazy-viewer-preload

Conversation

@mlightcad

Copy link
Copy Markdown
Owner

Summary

  • Defer @mlightcad/cad-simple-viewer to a dynamic import via viewerLoader, so the upload homepage entry stays free of a static viewer dependency
  • Schedule idle-time preload after first paint; clear cached promises on failure so a later open can retry
  • Keep Vite __vitePreload / modulepreload helpers in a separate vite-preload chunk so the entry does not pull in the full viewer graph

Test plan

  • Load the default demo: confirm upload UI paints before viewer chunks download (Network tab)
  • Open a DXF/DWG shortly after load (preload should already be warm)
  • Open a file immediately on first paint (initialize awaits in-flight preload)
  • Load mainNoPlugin / no-plugin page and confirm plugins are not fetched
  • Confirm built chunks: entry does not statically import cad-simple-viewer-*.js; vite-preload chunk exists

Keep the upload homepage free of a static cad-simple-viewer import so the entry stays small, warm modules in idle time, and isolate Vite preload helpers from the viewer chunk.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mlightcad
mlightcad merged commit 54506a5 into main Aug 11, 2026
2 checks passed
@mlightcad mlightcad self-assigned this Aug 15, 2026
@mlightcad mlightcad added the enhancement New feature or request label Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant