Skip to content

Conversation

@elliott-with-the-longest-name-on-github
Copy link
Contributor

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Jan 8, 2026

Adds a new experimental flag to gate the use of Svelte's fork API for preloading. The flag defaults to false, disabling the fork-based preloading behavior until explicitly enabled.

We're making this change because the current behaviour is buggy in some cases, such as when a redirect occurs when rendering the destination, and we don't want people to be prevented from updating to the latest version.


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.

Adds a new experimental flag to gate the use of Svelte's `fork` API for
preloading. The flag defaults to `false`, disabling the fork-based
preloading behavior until explicitly enabled.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

🦋 Changeset detected

Latest commit: e2451ef

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

@svelte-docs-bot
Copy link

Copy link
Member

@Conduitry Conduitry left a comment

Choose a reason for hiding this comment

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

The PR description says "feat" but the changelog says "fix" and changesets bump says "patch". What do we want to call this?

I might be in favor of the changelog saying "breaking". I don't have a strong opinion about whether the bump itself should be minor or patch.

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github changed the title feat: add experimental.enhancedPreloading flag fix: add experimental.enhancedPreloading flag Jan 8, 2026
@elliott-with-the-longest-name-on-github
Copy link
Contributor Author

Hmm yeah, I'd be okay with putting breaking in the changelog. Lemme see what Rich says in review. I don't think it's technically "breaking" as it's more of a performance "regression" than an actual breaking API change.

@benmccann
Copy link
Member

I like fix and patch

}, /^config\.kit\.experimental\.tracing\.server should be true or false, if specified$/);
});

test('errors on invalid enhancedPreloading values', () => {
Copy link
Member

Choose a reason for hiding this comment

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

i'm not entirely sure we need these tests, which are just testing the existing config handling code, which should already be tested. There's nothing unique about this config key

Choose a reason for hiding this comment

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

Yeah, I figured they can't hurt -- they at least protect from regressions and cost basically nothing

Copy link
Member

Choose a reason for hiding this comment

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

yeah but we have equivalent tests for the others. and this test will only last as long as the flag remains

__SVELTEKIT_APP_DIR__: s(kit.appDir),
__SVELTEKIT_EMBEDDED__: s(kit.embedded),
__SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: s(kit.experimental.remoteFunctions),
__SVELTEKIT_ENHANCED_PRELOADING__: s(kit.experimental.enhancedPreloading),
Copy link
Member

Choose a reason for hiding this comment

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

I assume s() is turning it into a string. If so I think this will leave it enabled by default because false will be converted to the string 'false' which will be evaluated as true when you check the value

Copy link
Member

Choose a reason for hiding this comment

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

no, it won't — it will be interpreted as false, same as __SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__

Copy link
Contributor Author

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github Jan 8, 2026

Choose a reason for hiding this comment

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

Not quite. It's very confusing. It turns it into a string, which is false, but that string is injected as-is into the runtime code. So the string 'foo' would become foo in the runtime code replacement, and 'false' becomes the literal false

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

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

LGTM, though would like to give people a chance to come up with anything more descriptive than enhancedPreloading...

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Conduitry Conduitry changed the title fix: add experimental.enhancedPreloading flag fix: add experimental.forkPreloads flag Jan 8, 2026
@Rich-Harris Rich-Harris merged commit 850bd56 into main Jan 9, 2026
25 checks passed
@Rich-Harris Rich-Harris deleted the elliott/add-experimental-preload-flag branch January 9, 2026 00:44
This was referenced Jan 8, 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.

5 participants