Repository navigation
Conversation
Monaco (~3.7MB) and pdfjs were statically imported by the session file viewer, so every app load paid for both even when the user never opened a code file or a PDF. Follow the existing office-preview convention and load them on demand. - SessionMonacoTextViewer -> LazySessionMonacoTextViewer (React.lazy + Suspense, Spinner fallback) at both call sites in session-file-content-view and the two in mobile-project-file-browser. - session-monaco-language-providers kept a top-level monaco import just for monaco.Uri. The code-collab URI scheme + fileId->provider registry moved to code-collab-monaco-model-provider.ts, which is monaco-free (hand-rolled URI build/parse, byte-identical to monaco.Uri output). The old module re-exports it and keeps monaco only for the language providers that run inside the editor chunk. - SessionFilePdfPreview -> lazy() + Suspense, matching the office renderer pattern. pdf-file-preview's static pdfjs import became type-only; createLocalPdfRangeTransport dynamically imports the new pdf-range-transport module. Electron renderer build emits session-monaco-text-viewer-*.js (3.69MB), pdf-*.js (495kB) and session-file-pdf-preview-*.js (229kB) as async chunks; the main entry no longer contains monaco/pdfjs code. Model: magpie/orchestrator
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
session-detailchunk statically bundled Monaco (~3.7 MB decoded) and PDF.js. Every app session paid the download+parse cost even when no text/PDF file was ever opened. The office preview renderer already usesawait import()— Monaco/pdfjs were the only heavy viewers still eager.What
lazy-session-monaco-text-viewer.tsx—React.lazy+Suspensewrapper aroundSessionMonacoTextViewer; same props, spinner fallback while the 3.7 MB monaco chunk loads.code-collab-monaco-model-provider.ts— monaco-free module extracted so URI build/parse helpers no longer pullmonaco-editorinto the boot chunk;buildCodeCollabMonacoUricallers insession-file-content-viewnow point here.pdf-range-transport.ts— extracted so the PDF streaming transport can be used without statically importingpdfjs-dist.session-file-binary-preview.tsx—SessionFilePdfPreviewbehindReact.lazy.mobile-project-file-browser.tsx— monaco viewer behind lazy boundary.session-file-content-view.tsx,session-monaco-*.ts— imports rewired to lazy/monaco-free modules.session-share-publisher.ts— zstdawait import('@loro-dev/streams-crdt/zstd')(also part of the wasm-deferral line; harmless here).Verification
apps/electronrenderer build emitsmonacoas a separate 3.69 MB async chunk and pdfjs worker as separate lazy chunks — verified in build output.tsc --noEmitclean inpackages/sharedandpackages/components.No behavior change — same props, same keys, same loading fallbacks; the spinner is the only new visible state while the monaco chunk fetches on first open.