Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.6k
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
base:main
Are you sure you want to change the base?
Conversation
changeset-botbot commentedJun 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🦋 Changeset detectedLatest commit:8f5a073 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
using
, link top-level using declarations in components to lifecycleusing
, link top-levelusing
declarations in components to lifecycleFun idea frombsky — |
ejsmith commentedJun 25, 2025
So that would be like a 1 time $derived value? |
Uh oh!
There was an error while loading.Please reload this page.
https://github.com/tc39/proposal-explicit-resource-management
Alternative to#16190, with the distinction that
using
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-level
using
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
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint