Repository navigation
perf: the dashboard fetches each page the first time it is opened - #102
Merged
Merged
Conversation
Signed-off-by: alkhatibdev <me@alkhatib.dev>
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.
The dashboard fetches each page the first time it is opened
The dashboard's script was one file of 847 kB (248 kB gzipped), and every build warned that it was
over Vite's 500 kB. This pull request splits it by page.
What changes
Router's
lazy.the rest in the other. Both keep their names through a release that changes only the
dashboard's code, so a browser keeps them.
The build no longer warns.
What splitting brings with it
have. When a page's file cannot be fetched, the dashboard loads the page somebody was opening
from the server, which brings the new files (
lib/upgrade.ts). When it did that less than tenseconds before, the file is missing for some other reason, and it does not load again.
inside the frame, so the menu stays. A page that failed to draw used to get React Router's own
error screen.
shows while it checks the session.
Tests
lib/upgrade.test.ts: when the dashboard loads a page again, and where to.router.test.tsx: a page whose file cannot be fetched, inside the frame and outside it. Bothtests fail without the error boundaries.
file:
Shell.test.tsx,Policies.test.tsxandSignIn.test.tsx.lazyis a function. Written as an object (lazy: { Component }), the tests'routers answered "No route matches" on a page's first visit, though the built dashboard did
not.
Checked
CI=trueand an empty npm cache: the clientagainst the contract, lint, types, format, 137 tests, and the build, with no size warning.
The image build was not run locally; CI runs it.
and a stand-in API: a signed-out visit sent to the sign-in page; a page's file fetched only
when the page opens; an upgrade with a tab open, after which the next page loads from the new
release; and a release with a page's file missing, which loads once more and then shows the
error inside the frame. No console errors and no CSP violations in any of them.