Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: supportusing, link top-levelusing declarations in components to lifecycle#16192

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Rich-Harris wants to merge8 commits intomain
base:main
Choose a base branch
Loading
fromusing-dispose

Conversation

Rich-Harris
Copy link
Member

@Rich-HarrisRich-Harris commentedJun 17, 2025
edited
Loading

https://github.com/tc39/proposal-explicit-resource-management

Alternative to#16190, with the distinction thatusing declarations at the top level of a component are only disposed when the component unmounts.

I think I prefer this — it's more useful and more intuitive.Demo here.

On the server it doesn't transform anything, meaning resources are correctly disposed of once rendering is complete. Obviously all this is of limited use until support is sufficiently widespread, but I don't see any reason to hold it back until then. (The demo above actually works in all browsers, because top-levelusing gets compiled away for client code, but that doesn't apply to server code or non-top-levelusing.)

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 withfeat:,fix:,chore:, ordocs:.
  • 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 withinpackages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests withpnpm test and lint the project withpnpm lint

mojoaxel, GauBen, PatrickG, aster-void, Ocean-OS, and SikandarJODD reacted with thumbs up emojiSikandarJODD reacted with heart emoji
@changeset-botchangeset-bot
Copy link

changeset-botbot commentedJun 17, 2025
edited
Loading

🦋 Changeset detected

Latest commit:8f5a073

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

This PR includes changesets to release 1 package
NameType
svelteMinor

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

@Rich-HarrisRich-Harris mentioned this pull requestJun 17, 2025
6 tasks
@github-actionsGitHub Actions
Copy link
Contributor

Playground

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

@Rich-HarrisRich-Harris changed the titlefeat: supportusing, link top-level using declarations in components to lifecyclefeat: supportusing, link top-levelusing declarations in components to lifecycleJun 17, 2025
@Rich-Harris
Copy link
MemberAuthor

Fun idea frombskyusing x = $derived(...). Like regularusing this would also be disposed on component unmount, but would additionally be disposed when the derived updated. Not quite sure what would happen outside the top level of a component though... maybe it would be forbidden to use it with unowned deriveds

@ejsmith
Copy link

Fun idea frombskyusing x = $derived(...). Like regularusing this would also be disposed on component unmount, but would additionally be disposed when the derived updated. Not quite sure what would happen outside the top level of a component though... maybe it would be forbidden to use it with unowned deriveds

So that would be like a 1 time $derived value?

@Rich-HarrisRich-Harris marked this pull request as draftJuly 16, 2025 21:53
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Rich-Harris@ejsmith

[8]ページ先頭

©2009-2025 Movatter.jp