Perf/lazy load heavy libs - #242
Merged
Merged
Conversation
Defer ~1.3MB of tool-specific JS off route-initial bundles by loading heavy libraries on first use instead of statically: - svgo (525KB): dynamic import in svg-optimize.ts, loads on first optimize - sql-formatter (278KB): dynamic import in sql-formatter-layout - vanilla-jsoneditor (485KB): JSONEditor dynamic-imported on mount in vanilla-editor; json-formatter-layout's Mode/toTextContent made type-only so the editor barrel is no longer dragged into the route chunk. toTextContent reimplemented locally (compact JSON, matches upstream default — verified against vanilla-jsoneditor across 10 cases). Also: - Delete dead exportUtils.ts (orphaned; only static xlsx import in repo; live consumers already lazy-load xlsx). - Pin Node floor: engines.node >=20.19.0 + .nvmrc=22. Below 20.19, undici in /api/proxy-ntlm breaks the build (markAsUncloneable). - Fix analyze script: next build --webpack (@next/bundle-analyzer is a no-op under Next 16's default Turbopack). Verified: Turbopack prod build green (86 routes), tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
svg-optimizer runs on every (debounced) keystroke; on large documents svgo's parse/optimize blocked the main thread and janked typing. Move it off-thread, mirroring the existing bcrypt/mock-data worker pattern: - svg-optimize.worker.ts + use-svg-optimize-worker.ts (id-keyed request/response, lazy worker, reject in-flight on unmount/error, main-thread fallback). - shouldUseSvgWorker gates on SVG_WORKER_MIN_CHARS (15k) — below that, main-thread optimize beats the worker round-trip + svgo chunk load. - svg-optimizer-layout calls the hook instead of optimizeSvgMarkup directly; svgo now loads inside the worker, never on the main thread (fallback aside). Verified: Turbopack prod build green (worker chunk emitted), tsc clean, svgo optimize contract checked (strips comments, shrinks output). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
No description provided.