chore: fix hydration treeshaking (#16767)

* chore: fix hydration treeshaking

* fix
pull/16769/head
Rich Harris 2 days ago committed by GitHub
parent 6a8ab8e008
commit ed3cb33b6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -63,8 +63,8 @@ export class Boundary {
/** @type {TemplateNode} */
#anchor;
/** @type {TemplateNode} */
#hydrate_open;
/** @type {TemplateNode | null} */
#hydrate_open = hydrating ? hydrate_node : null;
/** @type {BoundaryProps} */
#props;
@ -92,8 +92,6 @@ export class Boundary {
#is_creating_fallback = false;
#server_rendered_pending = false;
/**
* A source containing the number of pending async deriveds/expressions.
* Only created if `$effect.pending()` is used inside the boundary,
@ -131,10 +129,6 @@ export class Boundary {
this.#props = props;
this.#children = children;
this.#hydrate_open = hydrate_node;
this.#server_rendered_pending = this.#detect_server_state();
this.parent = /** @type {Effect} */ (active_effect).b;
this.#pending = !!this.#props.pending;
@ -143,8 +137,14 @@ export class Boundary {
/** @type {Effect} */ (active_effect).b = this;
if (hydrating) {
const comment = this.#hydrate_open;
hydrate_next();
if (this.#server_rendered_pending) {
const server_rendered_pending =
/** @type {Comment} */ (comment).nodeType === COMMENT_NODE &&
/** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;
if (server_rendered_pending) {
this.#hydrate_pending_content();
} else {
this.#hydrate_resolved_content();
@ -169,17 +169,6 @@ export class Boundary {
}
}
#detect_server_state() {
if (!hydrating || !this.#hydrate_open) return false;
const comment = this.#hydrate_open;
if (comment.nodeType === COMMENT_NODE) {
return /** @type {Comment} */ (comment).data === HYDRATION_START_ELSE;
}
return false;
}
#hydrate_resolved_content() {
try {
this.#main_effect = branch(() => this.#children(this.#anchor));
@ -344,7 +333,7 @@ export class Boundary {
}
if (hydrating) {
set_hydrate_node(this.#hydrate_open);
set_hydrate_node(/** @type {TemplateNode} */ (this.#hydrate_open));
next();
set_hydrate_node(remove_nodes());
}

Loading…
Cancel
Save