chore: faster builds with Vite 8 hook filters - #15439
Merged
Merged
Conversation
|
| Name | Type |
|---|---|
| @sveltejs/package | Major |
| @sveltejs/kit | Major |
| @sveltejs/enhanced-img | Major |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
benmccann
force-pushed
the
vite-filters
branch
2 times, most recently
from
February 26, 2026 22:01
0343bfb to
4648332
Compare
benmccann
force-pushed
the
vite-filters
branch
from
February 26, 2026 22:13
4648332 to
e5edb60
Compare
benmccann
force-pushed
the
vite-filters
branch
from
February 27, 2026 20:28
3e1e07b to
3c62417
Compare
teemingc
reviewed
Feb 28, 2026
teemingc
requested changes
Feb 28, 2026
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
benmccann
commented
Feb 28, 2026
teemingc
approved these changes
Mar 1, 2026
6 tasks
Rich-Harris
pushed a commit
that referenced
this pull request
Jul 17, 2026
Addresses part of #15461 `vite-plugin-sveltekit-guard` builds its `import_map` in every environment, but the map is only read in the `load` hook, which bails for non-client consumers before touching it. On the svelte.dev build that makes 69% of the guard's `resolveId` calls (3,987 of 5,778) dead work, and the guard was the top entry in dominikg's `PLUGIN_TIMINGS` report in #13756. This adds the same consumer bail to `resolveId`. The error chains from #14155 are unaffected because the client environment collects its own edges. Measured on the svelte.dev build with `3.0.0-next.6` and vite `8.0.16` (details in #15461 (comment)), ssr-side hook time drops from ~296s cumulative to 23ms, the build succeeds, and a planted two-hop `$lib/server` violation still fails with the full chain. There is no new test because the behavior is meant to be unobservable and the exact chain assertions already exist in `test/apps/dev-only` (dev) and `test/build-errors/server-only.spec.js` (build), both green with this change. History for reviewers. #15439 added hook filters everywhere except this hook, which is blocked on vitejs/vite#21956. #15543 proposed this skip plus a node_modules importer skip and was closed pending kit 3. The ssr half was not fixed by kit 3. The node_modules half is not implemented here because it is unsafe, a library can legitimately import `$app/server` and its violation chain has to walk node_modules edges. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
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 #13756
This PR is going to be hard to look at because of all the indentation changes, but basically I moved some
ifstatements in our Vite plugin hooks to afiltermethods to be faster. The changes themselves are pretty straightforward if you ignore the spacing changes. There was only one where it was a little gnarly to convert theifto a regex. I put a comment on that regex explaining what it's supposed to do