Skip to content

fix: skip prebundling of .remote.js files - #14583

Merged
Rich-Harris merged 3 commits into
mainfrom
skip-remote-prebundling
Oct 2, 2025
Merged

fix: skip prebundling of .remote.js files#14583
Rich-Harris merged 3 commits into
mainfrom
skip-remote-prebundling

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

Fixes at least part of #14519 — I couldn't get the repro to start up, because Vite's optimizeDeps step prebundles any dependencies it finds from +page.svelte and +page.js entry points. Import tracing should stop at .remote.js files, because these don't run in the client. This PR makes it so.


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.

@changeset-bot

changeset-bot Bot commented Oct 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59bf38a

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

@Rich-Harris

Copy link
Copy Markdown
Member Author

(this will probably need a Rolldown equivalent eventually)

@dummdidumm dummdidumm 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.

good apart from a small regex tweak

Comment thread packages/kit/src/exports/vite/index.js Outdated
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@Rich-Harris
Rich-Harris merged commit 342fed6 into main Oct 2, 2025
19 of 20 checks passed
@Rich-Harris
Rich-Harris deleted the skip-remote-prebundling branch October 2, 2025 21:12
This was referenced Oct 2, 2025
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
* fix: skip prebundling of .remote.js files

* robustify

* Update packages/kit/src/exports/vite/index.js

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Rich-Harris pushed a commit that referenced this pull request Jul 20, 2026
…kages can re-export remote functions (#16426)

Fixes #16353.

#14583 stops dependency tracing at `.remote.*` files by loading them as
empty modules during prebundling, so their server-only imports stay out
of the client bundle. An empty module also has no exports, so a package
entry that re-exports from a remote file kills the dev server during
dependency optimization

```
[MISSING_EXPORT] "lib_echo" is not exported by ".../data.remote.js"
   1 │ export { lib_echo } from './data.remote.js';
```

The docs say third party libraries can provide remote functions, so this
should work without per-package `optimizeDeps` config.

Externalizing the resolved id instead keeps tracing stopped and the
export surface intact, and the dev server serves the real module through
the normal transform. Build mode never ran the optimizer and stays
green.
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