feat: let a parent hold a child container weakly - #19
Merged
Conversation
A parent keeps a strong reference to every child it ever produced and releases it only when that child's destroy() runs. That is right by default, but wrong for a host that may build a container speculatively and then drop it without being told to — a React render that never commits retains one such container forever. The new `weakParentLink` option reaches the child through a WeakRef and prunes the registration with a FinalizationRegistry once the child is collected. Reachable children are still destroyed by the parent cascade, so the default path is untouched. Needs both ES2021 primitives; where either is missing it warns once and keeps the strong link. - child() now takes container options, with `parent` always this container - pin the build to target es2015, the floor the README advertises: with no target esbuild emitted esnext, shipping ES2022 class static blocks and ES2021 logical assignment - state what that pin does not cover — module-scope globalThis (ES2020) and the JSR package, which ships src/ rather than the bundle
bebrasmell
force-pushed
the
feat/weak-parent-link
branch
from
August 15, 2026 20:18
9ccd5d8 to
eb4ccf6
Compare
bebrasmell
commented
Aug 15, 2026
bebrasmell
left a comment
Contributor
Author
There was a problem hiding this comment.
lgtm, myself and I
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A parent keeps a strong reference to every child it ever produced and releases it only when that child's destroy() runs. That is right by default, but wrong for a host that may build a container speculatively and then drop it without being told to — a React render that never commits retains one such container forever.
The new
weakParentLinkoption reaches the child through a WeakRef and prunes the registration with a FinalizationRegistry once the child is collected. Reachable children are still destroyed by the parent cascade, so the default path is untouched. Needs both ES2021 primitives; where either is missing it warns once and keeps the strong link.parentalways this container