Skip to content

feat: enable optimizer for server environments during dev#1328

Merged
teemingc merged 16 commits into
mainfrom
optimize-server-deps
May 5, 2026
Merged

feat: enable optimizer for server environments during dev#1328
teemingc merged 16 commits into
mainfrom
optimize-server-deps

Conversation

@teemingc

@teemingc teemingc commented Apr 23, 2026

Copy link
Copy Markdown
Member

building on top of #1185

This PR ensures Svelte works correctly if the Vite dev server is in "full-bundle mode" (optimizeDeps on everything) such as when Cloudflare's Vite plugin is added. It ensures the dev server doesn't reload on initial page request and that Svelte is always bundled on the server unless specifically excluded.

The difference between this and the previous PR is an attempt to address Dominik's two concerns:

  1. Instead of simply copying the client optimized deps, we are also including server-only Svelte exports
  2. Moving the configuration from the setup plugin to the optimize plugin

@teemingc teemingc marked this pull request as draft April 23, 2026 13:27
@teemingc teemingc marked this pull request as ready for review April 23, 2026 13:47
@teemingc teemingc requested a review from Rich-Harris April 23, 2026 15:59

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@teemingc

teemingc commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

There's a test failing on Windows because of a letter drive difference in the sourcemap path 🤦🏼

EDIT: fixed in sveltejs/kit#15793

teemingc added a commit to sveltejs/kit that referenced this pull request May 4, 2026
Hope this helps fix
sveltejs/vite-plugin-svelte#1328 (comment)

EDIT: It does!

We don't need the `path.posix.resolve` variant since `to_fs` already
posixifies the path later (that code was also written almost 4 years
ago). Using it causes Windows to omit the letter drive, which misaligns
with Vite's own file resolution. I've verified it fixes the issue by
running CI tests with it in
sveltejs/vite-plugin-svelte#1328

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [ ] 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
- [ ] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests
- [ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets
- [ ] 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

- [ ] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.
@mrkishi

mrkishi commented May 4, 2026

Copy link
Copy Markdown
Member

Seems like it was unintentionally closed by the related PR.

@mrkishi mrkishi reopened this May 4, 2026
@teemingc teemingc merged commit 1a4d225 into main May 5, 2026
7 checks passed
@teemingc teemingc deleted the optimize-server-deps branch May 5, 2026 07:53
@github-actions github-actions Bot mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants