diff --git a/.changeset/hydrate-refusals.md b/.changeset/hydrate-refusals.md index e896c468c1..88934dd269 100644 --- a/.changeset/hydrate-refusals.md +++ b/.changeset/hydrate-refusals.md @@ -8,4 +8,4 @@ - Solid: a split handler of several statements without semicolons whose statements start with a call of a component local (`setCount(…)` then `setOpen(true)`) no longer runs as one call chain. - Solid: `ref={el!}`, `ref={el as T}` and `ref={(el)}` in split children assign the component's `let`, as `ref={el}` does. - React: a function in split children that reads a `let` the component reassigns now fails the build at the read, naming the variable: the split children receive its value when the boundary renders, so the function would not see later assignments. Keep the value in a ref (`useRef`), or use `split={false}`. Solid reads such a variable through a getter and is unaffected. -- The deferred hydration guide now lists every pattern that fails the build. Two of them built before and miscompiled silently: assigning a local of the component inside the boundary, and assigning a module-level variable the rest of the module also uses. Also refused: `await`/`yield` directly in the children, `new.target`, reading at module evaluation a binding later top-level code changes, and (Solid) a nested boundary assigning an outer local through `ref`. +- The deferred hydration guide now lists every pattern that fails the build. Two of them built before and miscompiled silently: assigning a local of the component inside the boundary, and assigning a module-level variable other code of the module also uses (the split code would write its own copy, or a binding it imports). Also refused: `await`/`yield` directly in the children, `new.target`, and (Solid) a nested boundary assigning an outer local through `ref`. diff --git a/docs/start/framework/react/guide/deferred-hydration.md b/docs/start/framework/react/guide/deferred-hydration.md index 3b7329ad7c..a8afd5b4c0 100644 --- a/docs/start/framework/react/guide/deferred-hydration.md +++ b/docs/start/framework/react/guide/deferred-hydration.md @@ -712,8 +712,7 @@ These patterns cannot be split: | Hook calls directly inside extracted JSX | Moving that JSX would move where the hook executes. | Move the hook call into a component inside the boundary, then render that component. | | A function inside the boundary reading a `let` the component reassigns | The extracted children receive the variable's value when the boundary renders: the function would not see later assignments. | Keep the value in a ref (`const timer = useRef()`, read and assign `timer.current`), or use `split={false}`. | | Assigning a local of the component inside the boundary (`count++`) | The extracted children receive the local's value, not the variable. | Move the variable and the code that assigns it into a component inside the boundary, or use `split={false}`. | -| Assigning a module-level variable the rest of the module also uses | Extracted code cannot assign a binding it imports. | Move the code that assigns it into a component defined outside the boundary and render that component inside it, or use `split={false}`. | -| Reading at module evaluation a binding that later top-level code changes | Extraction would change the order of evaluation. | Use `split={false}`. | +| Children assigning a module variable which other code of the module uses | Extracted code cannot assign a binding it imports. | Use `split={false}`: the chunk would write its own copy while the module reads the original, or it would assign the bindings it imports. | | `await` or `yield` directly inside the boundary | The extracted children render in a synchronous component. | Compute the value before the boundary, or use `split={false}`. | | `this` or `new.target` captures | Extracted function components cannot safely preserve class instance or constructor context. | Wrap the UI in a function component or use `split={false}`. | | `super` captures | Extracted function components cannot preserve superclass access. | Wrap the UI in a function component or use `split={false}`. | diff --git a/packages/compiler-test-utils/oracle/KNOWN-BUGS.md b/packages/compiler-test-utils/oracle/KNOWN-BUGS.md index 64ba5abacb..03bf711a14 100644 --- a/packages/compiler-test-utils/oracle/KNOWN-BUGS.md +++ b/packages/compiler-test-utils/oracle/KNOWN-BUGS.md @@ -166,6 +166,52 @@ code.test.ts`: "a root route's components load with the route module" (Vite and start-build-lazy-handlers.test.ts`, "SSR (R159) %s: …" and "SSR: a server fn a top-level statement names and the split component calls has one instance: 1 2 3 4". No test holds the three differences: they are the limit itself. +- **A `` chunk copies the module-level declarations its children reach, as `main`'s chunk does** (R155, R161 + D1; spec-phase2-hydrate H1). The copy is a second instance, and no top-level statement is copied. Bugs of `main` the + PR no longer fixes, each with its input (the children inside ``): + 1. a context created in the module: `const Theme = createContext('light')`, children `