Skip to content

Commit bc3dfdf

Browse files
committed
Merge remote-tracking branch 'origin/next' into claude/project-thread-x1ore2-4408
2 parents 5429aa0 + 6bde511 commit bc3dfdf

10 files changed

Lines changed: 50 additions & 7 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"solid-js": patch
3+
"@solidjs/web": patch
4+
---
5+
6+
`createOwner` leaves solid-js's public types: it is typed only through `solid-js/internal`, like the boundary primitives behind `Errored`, `Loading` and `Reveal` (#3709). It stays a runtime export for the renderers. Solid 1.x had no `createOwner`, and application code that used it in an RC should host a scope with `createRoot()` (its `dispose` argument can be passed around as a plain function) and re-enter one with `runWithOwner()`. A detached `owner.dispose` keeps throwing, since it is a method and not part of the public API (#4444).

‎packages/signals/tests/attribution.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,12 @@ describe("why-did-this-run attribution", () => {
503503
while (performance.now() < end);
504504
};
505505
const [n, setN] = createSignal(0, { name: "n" });
506+
// 40 ms, not 10: self-times are wall-clock, and on a loaded CI runner a
507+
// scheduling pause inside the cheap effect measured 17.9 ms against the
508+
// memo's 10.1 ms. The ranking asserted below needs the gap to be wide.
506509
const slow = createMemo(
507510
() => {
508-
spin(10);
511+
spin(40);
509512
return n();
510513
},
511514
{ name: "slow-memo" }

‎packages/signals/tests/treeshake.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ function retainedFrom(retained: string[], names: string[]): string[] {
6767
return names.filter(name => retained.some(id => id.includes(name)));
6868
}
6969

70-
describe("pay-for-use tree-shaking (#2883)", () => {
70+
// Every test runs a full Vite build of a fixture, and the first one pays the
71+
// bundler's cold start: under the whole suite's load on CI it ran past
72+
// vitest's 5 s default (5,295 ms) while asserting nothing wrong.
73+
describe("pay-for-use tree-shaking (#2883)", { timeout: 30_000 }, () => {
7174
it("core floor sheds every optional feature module", async () => {
7275
const { minifiedBytes, retained } = await bundleFixture(
7376
`export { createSignal, createMemo, createEffect, createRoot, flush } from "sigsrc";`

‎packages/solid/src/index.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export {
33
$TRACK,
44
action,
55
affects,
6-
createOwner,
76
createReaction,
87
createTrackedEffect,
98
deep,
@@ -41,6 +40,12 @@ export {
4140
} from "@solidjs/signals";
4241
/** @internal — the key a root owner carries `render`'s `onError` under, for the web runtime. */
4342
export { ROOT_ERROR_HOOK } from "@solidjs/signals";
43+
// `createOwner`: a bare owner, for the runtimes' own scopes (`NoHydration`,
44+
// `Portal`, a frame's fill). Exported at runtime (typed for renderers through
45+
// `solid-js/internal`), `@internal` because application code hosts a scope
46+
// with `createRoot()` and re-enters one with `runWithOwner()`, as in 1.x.
47+
/** @internal */
48+
export { createOwner } from "@solidjs/signals";
4449
export { from } from "./from.js";
4550

4651
export type {

‎packages/solid/src/internal.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
* The boundary primitives behind `Errored`, `Loading`, and `Reveal` are
2626
* read back the same way (real on both entries), for renderers that
2727
* build boundaries without the components, and so are `sharedConfig`
28-
* (the hydration/SSR coordination object) and the `$DEVCOMP` brand.
28+
* (the hydration/SSR coordination object), the `$DEVCOMP` brand and
29+
* `createOwner` (a bare owner for a runtime's own scope).
2930
*
3031
* Not here: the container-trace materializer. It lives in its own entry,
3132
* `solid-js/internal/container-trace`, so the store engine it builds on can
@@ -37,6 +38,7 @@ import type {
3738
Accessor,
3839
Component,
3940
DynamicOptions,
41+
Owner,
4042
RevealOrder,
4143
ServerErrorHook,
4244
ServerErrorSite
@@ -171,6 +173,19 @@ export const getProjectionTrace: (
171173
export const shareAsyncIterable: <T>(source: AsyncIterable<T>) => AsyncIterable<T> =
172174
core.shareAsyncIterable;
173175

176+
/**
177+
* A fresh owner under the current one (or a detached root if there is none),
178+
* for a runtime's own scope: `NoHydration`, `Portal`, a frame's fill. `id`
179+
* seeds the hydration ids of the tree it owns; `transparent` lets that tree
180+
* draw ids from the parent's counter. Its `dispose` is a method
181+
* (`owner.dispose()`), not a detached function. Not application API: an app
182+
* hosts a scope with `createRoot()` and re-enters one with `runWithOwner()`.
183+
*/
184+
export const createOwner: (options?: {
185+
id?: string;
186+
transparent?: boolean;
187+
}) => Owner & { dispose(self?: boolean): void } = core.createOwner;
188+
174189
/** The primitive behind `<Errored>`: `fn()`, or `fallback(error, reset)` once something under it throws. */
175190
export const createErrorBoundary: <T, U>(
176191
fn: () => T,

‎packages/solid/src/server/index.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export {
1313
createDeferred,
1414
createOptimistic,
1515
createOptimisticStore,
16-
createOwner,
1716
createProjection,
1817
createReaction,
1918
createRenderEffect,
@@ -58,6 +57,12 @@ export {
5857
ROOT_ERROR_HOOK
5958
} from "./signals.js";
6059
export type { ClientErrorContext, ClientErrorHook, ClientErrorsConfig } from "./signals.js";
60+
// `createOwner`: a bare owner, for the runtimes' own scopes (`NoHydration`,
61+
// `Portal`, a frame's fill). Exported at runtime (typed for renderers through
62+
// `solid-js/internal`), `@internal` because application code hosts a scope
63+
// with `createRoot()` and re-enters one with `runWithOwner()`, as in 1.x.
64+
/** @internal */
65+
export { createOwner } from "./signals.js";
6166

6267
// All type re-exports from signals
6368
export type {

‎packages/web/frames/src/client.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import {
2020
OBSERVE,
2121
createMemo,
22+
// @ts-expect-error `createOwner` is `@internal` in solid-js's declarations (typed in
23+
// solid-js/internal); importing it from solid-js keeps it one binding in the bundle.
2224
createOwner,
2325
createRenderEffect,
2426
createSignal,

‎packages/web/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
import {
1414
createComponent,
1515
createMemo,
16+
// @ts-expect-error `createOwner` is `@internal` in solid-js's declarations (typed in
17+
// solid-js/internal); importing it from solid-js keeps it one binding in the bundle.
1618
createOwner,
1719
createRoot,
1820
createSignal,

‎packages/web/test/runtime/head.spec.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
* first registration and stays for the whole file.
1313
*/
1414
import * as r from "../../src/client.js";
15-
import { createRoot, createSignal, flush, createOwner, runWithOwner } from "solid-js";
15+
import { createRoot, createSignal, flush, runWithOwner } from "solid-js";
16+
import { createOwner } from "solid-js/internal";
1617
import { peekNextChildId } from "@solidjs/signals";
1718

1819
// Registry applies on a microtask.

‎packages/web/test/wait-asset.spec.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* allocated after the call).
1414
*/
1515
import { describe, expect, test } from "vitest";
16-
import { createRoot, createOwner, runWithOwner, getNextChildId, flush } from "solid-js";
16+
import { createRoot, runWithOwner, getNextChildId, flush } from "solid-js";
17+
import { createOwner } from "solid-js/internal";
1718
import { effect } from "../src/render.js";
1819
import { waitAsset } from "../src/client.js";
1920

0 commit comments

Comments
 (0)