breaking: change preloadCode(pathname) to preloadCode(routeId), make match pre-resolve loaders - #16576
Open
elliott-with-the-longest-name-on-github wants to merge 5 commits into
Open
Conversation
`match` pre-resolve loaders
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/49c99c016230cab05048cb340fcfe1e739772ea8Open in |
🦋 Changeset detectedLatest commit: 49c99c0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ing (#16578) Stacked on #16576, per #16576 (comment). `dependencies` is per-`visit()`, so the route-ID module was generated once per prerendered page. On the `prerendering/basics` fixture with `resolution: 'server'`, 31 generations produced 28 files; with this, 28 produce 28, and the output is byte-identical apart from the build version stamp.
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.
closes #16511
The top-of-the-line goal of this PR is to change
preloadCode(pathname)topreloadCode(routeId). This just makes more sense -- the code corresponds to the route you wrote, not the pathname you might be requesting. If you need to resolve a pathname to a route ID, you can always do this:In order to enable this without creating unnecessary waterfalls (where
matchhas to go to the server, and thenpreloadCodehas to go to the server to resolve the route id to its loaders),matchcaches its resolutions' loaders when it executes.Basically what this means is that:
matchresolution is trivial, because the full routing manifest is available clientside alreadymatchconsults the server for the route definition, then immutably caches the route and its loaders for future reference bypreloadCodeThere's one additional challenge: When
preloadCodeis called with a route ID that wasn't resolved usingmatch, it has no cache entry to pull the loaders from. It can't usematchinternally to resolve the route, becausematchoperates on pathnames and has no ability to resolve a route ID. To enable this, this PR adds an_app/routes/[...id]/__route.jsendpoint that operates very similarly to the existing serverside route resolution and allows resolving route IDs to their route info. This enablespreloadCodeto fall back to actually looking up the information if it hasn't been pre-resolved and cached.