Svelte

fix: rework lazily remote function files discovery

#14456

Closing issue

Pull request

Closed
D
dummdidumm
Sep 17, 2025, 6:43 PM

Instead of using manualChunks which turns out to cause some weird chunking bugs, we instead use a virtual module which we force to be loaded at the very end after all other modules have been discovered. By that time we have collected all remote function files and can generated a record of hash->import. Vite will then do the proper chunking without further interference by us. Thanks @bluwy for the tip!

Fixes and possibly and

Putting this into draft because while working on this I discovered that remote functions in node_modules are not loaded at dev time - but this is not new to this PR, it's failing on main, too. Investigating. Also fixes a bug in dev mode where remote functions might not be transformed if Vite decides to append a query parameter (we checked if the file ends with .remote.js/ts but they could end with .remote.js/ts?v=123)


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

Info

Closed at Oct 2, 2025, 7:48 PM
Assignees None
Reviewers None
Labels None
Milestone None

Pro tip: You can prefix GitHub URLs of issues, PRs or discussions with svcl.dev/ to view them on this page! Also try it on a GitHub release ;)