Skip to content

fix: use fine grained for template if the component is not explicitly in legacy mode #16232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 25, 2025

Conversation

paoloricciuti
Copy link
Member

@paoloricciuti paoloricciuti commented Jun 24, 2025

Closes #16199
Closes #16229
Closes #16194

The ideal would've been to refactor runes from a boolean to an enum but I'll be honest I was quite scared of touching it because there are a bunch of places where we use it and we also move it to other variables...basically if we skip one of this it will break stuff.

So i went for a maybe_runes boolean that checks there's any trace of explicit legacy mode:

  • export let
  • $$props or $$restProps
  • <svelte:options runes={false} />

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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Jun 24, 2025

🦋 Changeset detected

Latest commit: ed16aa2

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

This PR includes changesets to release 1 package
Name Type
svelte 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
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16232

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Looks good apart from one check

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Mhhhm will these tests actually test this correctly? IIRC runtime-runes forces all components to compile in runes mode. Might need some test setup tweaks

@paoloricciuti
Copy link
Member Author

Mhhhm will these tests actually test this correctly? IIRC runtime-runes forces all components to compile in runes mode. Might need some test setup tweaks

Uhm...yeah I think yes...let me change that

@paoloricciuti
Copy link
Member Author

I tweaked the test suite to give precedence to the defined runes option if present, i've also added more tests

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Great work!

@dummdidumm dummdidumm merged commit 922bee9 into main Jun 25, 2025
14 checks passed
@dummdidumm dummdidumm deleted the legacy-in-between-mode branch June 25, 2025 09:35
@github-actions github-actions bot mentioned this pull request Jun 25, 2025
@gyzerok
Copy link
Contributor

gyzerok commented Jun 25, 2025

@paoloricciuti does it mean that now I can expect runes mode to be a default until I explicitly enable legacy mode?

@paoloricciuti
Copy link
Member Author

@paoloricciuti does it mean that now I can expect runes mode to be a default until I explicitly enable legacy mode?

Not exactly...this only really applies to the template, since before #16100 reading state in the template of a legacy component would still track said state.

Now if we are not 100% sure the component it's in legacy mode we preserve that behaviour but as soon as you use something that clearly define the mode (like export let or $: or $$props etc) you'll be in legacy mode.

@gyzerok
Copy link
Contributor

gyzerok commented Jun 25, 2025

Sound great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants