Skip to content

fix: posixify optimizeDeps.entries so Vite can scan routes on Windows - #17757

Merged
teemingc merged 4 commits into
sveltejs:mainfrom
dxxxxy:fix/optimize-deps-entries-windows
Nov 14, 2026
Merged

teemingc merged 4 commits into
sveltejs:mainfrom
dxxxxy:fix/optimize-deps-entries-windows

Conversation

@dxxxxy

@dxxxxy dxxxxy commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

On Windows, the optimizeDeps.entries patterns SvelteKit gives Vite match no files, so Vite's dependency scanner finds nothing at dev server startup.

kit.files.routes is resolved to an absolute OS path, so on Windows it contains backslashes, and it's interpolated straight into the glob:

entries: [
	`${kit.files.routes}/**/+*.{svelte,js,ts}`,
	`!${kit.files.routes}/**/+*server.*`
],

Vite passes the patterns to tinyglobby unchanged, and in a glob \ is an escape character. With the same options Vite uses:

C:\path\to\app\src\routes/**/+*.{svelte,js,ts}  -> 0 files
C:/path/to/app/src/routes/**/+*.{svelte,js,ts}  -> 23 files

What users see

On a cold start (node_modules/.vite empty), the scanner finishes in a few milliseconds and reports the scanner found every used dependency. Vite then discovers dependencies only as the browser requests them, re-bundles each batch, and logs optimized dependencies changed. reloading, so the first page loads reload one or more times. If you click a link during that window, the reload sends you back to the page you started on.

Fix

Run the path through posixify, which this file already uses for out_dir, the service worker entry and appDir.

Testing

On Windows 11 (Node 24, Vite 8.3.4, Kit 3.1.0), I patched the installed package with this change and cold-started a dev server for an app with about 20 routes. Before the change, the scanner took about 10 ms, found nothing, and the page reloaded twice. After it, the scanner took about 3 s, found every dependency up front, and nothing reloaded. Without the patch, adding the same patterns as relative paths to optimizeDeps.entries in vite.config.ts works around it.

I didn't add a test: the config hook isn't unit tested today, and covering this would need a Windows CI run.

On Linux (Ubuntu 24.04 under WSL, Node 24.22), pnpm lint, pnpm check and the unit tests pass, and so does every integration app except two tests in basics (hides announcer and Cookies API › works with basic enhance). Those also fail intermittently without this change, and passed 10 out of 10 runs each both with and without it. On Linux the change is a no-op, since posixify returns a path that already uses forward slashes unchanged. I ran the integration tests with Playwright's bundled Chromium instead of the chrome channel, because Chrome isn't installed in WSL.

On Windows, unit tests and pnpm check pass. Lint flags CLAUDE.md and .github/copilot-instructions.md, which are symlinks that Git on Windows checks out as plain files. A few integration tests fail with and without this change: the ones that spawn pnpm without a shell (ENOENT), the options-2 service worker test, whose expected path is built with path.join and so uses backslashes, and a few timing-sensitive tests in basics. One of those, data-sveltekit-preload-code, fails more often on Windows with this change (about 9 of 26 runs, against about 1 of 25 without it). Its first assertion counts node responses right after the hover, without the networkidle wait the later assertions use, so it can count before the eager preload has arrived (it receives 3 of the expected 4). With pre-bundling now working, the startup timing differs. Adding the same wait to that assertion brought it to 1 failure in 40 runs.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

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:.

🤖 Generated with Claude Code

kit.files.routes is an absolute OS path, and its backslashes are escape
characters in a glob, so on Windows the entries matched no files and the
dependency scanner found nothing at startup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pkg-svelte-dev

pkg-svelte-dev Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 8d43876:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/8d4387669fc5cc3693b0408f9f966adfd30f5209

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17757

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d43876

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@teemingc
teemingc merged commit ccd3474 into sveltejs:main Nov 14, 2026
37 of 38 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 14, 2026
teemingc pushed a commit that referenced this pull request Nov 17, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @sveltejs/[email protected]

### Patch Changes

- fix: set `X-Accel-Buffering: no` on `text/event-stream` responses
whose content type has parameters, such as `charset=utf-8`
([#17687](#17687))
- Updated dependencies:
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Patch Changes

- fix: support all bundle strategies with Vercel Skew Protection
([#17731](#17731))
- Updated dependencies:
  - @sveltejs/[email protected]
## @sveltejs/[email protected]

### Patch Changes

- fix: check the return value of async `load` functions against
`App.PageData` ([#17793](#17793))

- fix: prerender crawler finds links located after a quoted attribute
value ending with `\`
([#17688](#17688))

- fix: omit nopush from preload Link headers so Chromium can use CDN
Early Hints ([#17786](#17786))

- perf: hash a page's encoded bytes for its `ETag` and send the same
bytes as the body, and skip the hash when `setHeaders` already sets an
`etag` or the response is `no-store`
([#17674](#17674))

- chore: deprecate `adapter.emulate`
([#17769](#17769))

- fix: generate valid types for route params whose names start with a
digit, such as `[2nd]`
([#17661](#17661))

- perf: skip the `ETag` hash for a page that has a CSP nonce in it,
since no two responses are the same
([#17743](#17743))

- fix: correctly scan routes on Windows when optimising dependencies
([#17757](#17757))
## @sveltejs/[email protected]

### Patch Changes

- fix: remove transformed output files when sources are deleted in watch
mode ([#17519](#17519))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
dadezzz pushed a commit to dadezzz/events-cash-register that referenced this pull request Nov 22, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@sveltejs/kit](https://svelte.dev) ([source](https://github.com/sveltejs/kit/tree/HEAD/packages/kit)) | [`3.2.0` → `3.4.0`](https://renovatebot.com/diffs/npm/@sveltejs%2fkit/3.2.0/3.4.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@sveltejs%2fkit/3.4.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@sveltejs%2fkit/3.2.0/3.4.0?slim=true) |

---

### Release Notes

<details>
<summary>sveltejs/kit (@&#8203;sveltejs/kit)</summary>

### [`v3.4.0`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#340)

[Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/[email protected]...@sveltejs/[email protected])

##### Minor Changes

- feat: allow adapters to disable SvelteKit's Node preview server with `vite.customPreview: true` when providing their own preview implementation ([#&#8203;17750](sveltejs/kit#17750))

- feat: add `sveltekit.remote.call.file` attribute to remote function tracing spans ([#&#8203;17760](sveltejs/kit#17760))

##### Patch Changes

- fix: strip trailing route groups when resolving routes with search parameters or fragments ([#&#8203;17808](sveltejs/kit#17808))

- fix: correctly display non-ASCII characters for plain text error messages during development ([#&#8203;17468](sveltejs/kit#17468))

- fix: explain missing TypeScript compiler API instead of crashing with TypeScript 7 ([#&#8203;17539](sveltejs/kit#17539))

- fix: reject remote function requests that use the wrong HTTP method ([#&#8203;17740](sveltejs/kit#17740))

- fix: respect `NO_COLOR` and explicit `FORCE_COLOR` settings in forked build processes ([#&#8203;17618](sveltejs/kit#17618))

### [`v3.3.1`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#331)

[Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/[email protected]...@sveltejs/[email protected])

##### Patch Changes

- fix: read environment variables for route analysis and prerendering after all adapter Vite `config` hooks have run ([#&#8203;17559](sveltejs/kit#17559))

- fix: respect a user-set `build.cssMinify` ([#&#8203;17797](sveltejs/kit#17797))

- fix: don't serialize the results of remote functions awaited in server `load` functions into the page ([#&#8203;17759](sveltejs/kit#17759))

### [`v3.3.0`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#330)

[Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/[email protected]...@sveltejs/[email protected])

##### Minor Changes

- feat: support the Vite DevTools dock in dev ([#&#8203;17787](sveltejs/kit#17787))

### [`v3.2.1`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#321)

[Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/[email protected]...@sveltejs/[email protected])

##### Patch Changes

- fix: check the return value of async `load` functions against `App.PageData` ([#&#8203;17793](sveltejs/kit#17793))

- fix: prerender crawler finds links located after a quoted attribute value ending with `\` ([#&#8203;17688](sveltejs/kit#17688))

- fix: omit nopush from preload Link headers so Chromium can use CDN Early Hints ([#&#8203;17786](sveltejs/kit#17786))

- perf: hash a page's encoded bytes for its `ETag` and send the same bytes as the body, and skip the hash when `setHeaders` already sets an `etag` or the response is `no-store` ([#&#8203;17674](sveltejs/kit#17674))

- chore: deprecate `adapter.emulate` ([#&#8203;17769](sveltejs/kit#17769))

- fix: generate valid types for route params whose names start with a digit, such as `[2nd]` ([#&#8203;17661](sveltejs/kit#17661))

- perf: skip the `ETag` hash for a page that has a CSP nonce in it, since no two responses are the same ([#&#8203;17743](sveltejs/kit#17743))

- fix: correctly scan routes on Windows when optimising dependencies ([#&#8203;17757](sveltejs/kit#17757))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTUuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
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.

2 participants