Skip to content

Commit fb4e637

Browse files
ryansolidClaude via Cursorcursoragent
committed
Move sharedConfig and $DEVCOMP types to solid-js/internal; guard index.d.ts against stripped re-exports
Follow-up to #3709. `sharedConfig` and `$DEVCOMP` were tagged `@internal` at their declarations but re-exported from a public block of `solid-js`'s index, so `types/index.d.ts` still carried two dangling re-exports (TS2305 under skipLibCheck: false, `any` otherwise). Both move to the index's `@internal` block, so they remain runtime exports of `solid-js` on every build. `solid-js/internal` now declares them: `sharedConfig` gets one shape that is honest for both entries (every member optional, since the client object carries hydration state and the server object carries the render `context` and the id allocator), and `$DEVCOMP` is declared as `symbol`. The server entry tags the same names, plus `createErrorBoundary`, `createLoadingBoundary` and `createRevealOrder`, `@internal` the same way. Every in-repo consumer (web, frames, refresh, web tests) now imports them from `solid-js/internal`. published-declarations.spec.ts compiles a probe over every published types entry with skipLibCheck: false and requires the generated declarations to check clean. That covers this whole class of stripInternal bug, not just these names. internal-surface.spec.ts now pins the three boundary primitives, `sharedConfig` and `$DEVCOMP`. The REACTIVITY_HALTED message and its docs now point to `<Errored>` only. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 5bef430 commit fb4e637

27 files changed

Lines changed: 216 additions & 62 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"solid-js": patch
3+
"@solidjs/web": patch
4+
"@solidjs/signals": patch
5+
---
6+
7+
`sharedConfig` and `$DEVCOMP` are no longer part of `solid-js`'s public types; they are typed from `solid-js/internal` (not public API, no semver guarantee). Their runtime exports from `solid-js` are unchanged. Libraries that import `sharedConfig` from `solid-js` must switch to `solid-js/internal`. Under `skipLibCheck: false`, `solid-js`'s declarations now type-check clean (they re-exported both names after stripping them, #3709). The `REACTIVITY_HALTED` message now points to `<Errored>` only.

‎documentation/solid-2.0/03-control-flow.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ configureClientErrors({
160160
render(() => <App />, root, undefined, { onError });
161161
```
162162

163-
- Fires when an `Errored` (or `createErrorBoundary`) collected a failure and renders its fallback. An **uncaught** error is not this hook's: nothing contained it, the reactive system halts (`REACTIVITY_HALTED`), and the cause goes to the platform's `reportError` — `window.onerror`, the channel every monitor and every `addEventListener("error")` already listens on. One event, one channel.
163+
- Fires when an `Errored` collected a failure and renders its fallback. An **uncaught** error is not this hook's: nothing contained it, the reactive system halts (`REACTIVITY_HALTED`), and the cause goes to the platform's `reportError` — `window.onerror`, the channel every monitor and every `addEventListener("error")` already listens on. One event, one channel.
164164
- **Once per error object**: a `reset()` that recomputes the same failing node re-collects the same error and says nothing new; a primitive thrown has no identity and is reported per sight.
165165
- `ownerPath` is where the error was **thrown** — labels root-first up the owner chain of the computation that threw (component labels and named primitives; the compiler's inner memos ride along by their default name) — and `boundaryPath` where it was **met**, the same labels up the `<Errored>`'s own chain: what broke, and what the user saw. Both where the runtime keeps owner names (the observe and dev artifacts; production owners carry none). When the throw crossed no computation the engine could name, `ownerPath` is the boundary's.
166166
- No return: the client has no wire to map for. A throwing hook is reported on the console and ignored — a monitor never takes the app down.
167-
- Pay-for-use: the hook machinery rides with `createErrorBoundary` or the app's own `configureClientErrors` import; a root's hook is parked on the root owner, so `render` retains nothing for an app that passes none.
167+
- Pay-for-use: the hook machinery rides with `Errored` or the app's own `configureClientErrors` import; a root's hook is parked on the root owner, so `render` retains nothing for an app that passes none.
168168

169169
An effect's own error arm (`createEffect(compute, effect, onError)`) is the author handling the failure and is not reported here.
170170

‎documentation/solid-2.0/08-dev-diagnostics.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ Internal consistency check on the async settle walk (see `packages/signals/docs/
286286

287287
#### `REACTIVITY_HALTED`
288288

289-
**Message:** "An uncaught error halted the reactive system. No further updates will be processed. Handle errors with createErrorBoundary/<Errored> or treat this as a crash."
289+
**Message:** "An uncaught error halted the reactive system. No further updates will be processed. Handle errors with <Errored> or treat this as a crash."
290290

291291
A user error escaped every boundary and the scheduler stopped for good: app state is undefined at that point, so nothing limps on with a half-applied update. Emitted once, on the structured channel and to `console.error`; where the platform has `reportError`, the cause is handed to it as well, so `window.onerror` / error monitoring sees a halt that would otherwise leave a page that looks alive (a throw during the hydration render, #3338). The first write after a halt logs "Update ignored: the reactive system was halted" (once) and does nothing. Production halts the same way — the bare `[REACTIVITY_HALTED]` to `console.error`, the cause to `reportError` — without the structured event. An observability adapter should treat this code as a crash signal. (A failure a boundary _contained_ is the client error hook's — [RFC 03](03-control-flow.md#reporting-what-a-boundary-caught-the-client-error-hook); the halt itself is `reportError`'s.)
292292

‎documentation/solid-2.0/MIGRATION.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,7 @@ If you need a standard Observable/AsyncIterable interface for external consumers
10481048
- **`resetErrorBoundaries`** → no longer needed (error boundaries heal automatically)
10491049
- **`enableScheduling`** → removed
10501050
- **`writeSignal`** → removed (internal API that should not have been exported)
1051+
- **`sharedConfig` / `$DEVCOMP`** → no longer part of `solid-js`'s public types; renderers and tooling reach them through `solid-js/internal` (not public API — no semver guarantee, may change in any release)
10511052
- **`use:` directives** → `ref` directive factories
10521053
- **`attr:` / `bool:` namespaces** → standard attribute behavior
10531054
- **`on:` / `oncapture:`** → `onClick` for Solid events; ref callbacks for native listener options

‎packages/signals/src/core/scheduler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ export function haltReactivity(cause?: unknown): void {
532532
let message = "[REACTIVITY_HALTED]";
533533
if (__DEV__) {
534534
message +=
535-
" An uncaught error halted the reactive system. No further updates will be processed. Handle errors with createErrorBoundary/<Errored> or treat this as a crash.";
535+
" An uncaught error halted the reactive system. No further updates will be processed. Handle errors with <Errored> or treat this as a crash.";
536536
emitDiagnostic({
537537
code: "REACTIVITY_HALTED",
538538
kind: "error",

‎packages/solid/rollup.config.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ const build = (input, name, external, isDev, isObserve) => ({
4747

4848
const client = ["@solidjs/signals"];
4949
const server = ["@solidjs/signals", "stream"];
50-
// The refresh runtime imports the main entry ("solid-js") rather than
51-
// relative sources so it shares module state ($DEVCOMP, DEV) with the
52-
// solid-js instance the app resolves at build time.
53-
const refresh = ["solid-js", "@solidjs/signals"];
50+
// The refresh runtime imports the main entry ("solid-js", and its seams
51+
// through "solid-js/internal") rather than relative sources so it shares
52+
// module state ($DEVCOMP, DEV) with the solid-js instance the app resolves
53+
// at build time.
54+
const refresh = ["solid-js", "solid-js/internal", "@solidjs/signals"];
5455

5556
export default [
5657
build("src/index.ts", "solid", client, false, false),

‎packages/solid/skills/reactivity-diagnostics/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ before returning.
196196

197197
An earlier uncaught error halted the reactive system; subsequent updates are
198198
ignored. Do not treat this code as the bug — find the original error above
199-
it (or add an error boundary via `createErrorBoundary`/`<Errored>`) and fix
199+
it (or add an error boundary with `<Errored>`) and fix
200200
that.
201201

202202
### INVARIANT_VIOLATION

‎packages/solid/src/index.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export type {
8282
} from "@solidjs/signals";
8383

8484
// needs wrappers
85-
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
85+
export { children, createContext, useContext } from "./client/core.js";
8686

8787
export type {
8888
ChildrenReturn,
@@ -96,7 +96,6 @@ export * from "./client/component.js";
9696
export * from "./client/flow.js";
9797
export type { ArrayElement, Element } from "./types.js";
9898
export {
99-
sharedConfig,
10099
enableHydration,
101100
createRoot,
102101
createMemo,
@@ -114,7 +113,9 @@ export {
114113
// (src/internal.ts): exported here at runtime so that entry shares this
115114
// module's state, `@internal` so they are stripped from the declarations.
116115
/** @internal */
117-
export { materializeContainerTrace } from "./client/hydration.js";
116+
export { materializeContainerTrace, sharedConfig } from "./client/hydration.js";
117+
/** @internal */
118+
export { $DEVCOMP } from "./client/core.js";
118119
// The boundary primitives behind `Errored`, `Loading` and `Reveal`: exported
119120
// at runtime (typed for renderers through `solid-js/internal`), `@internal`
120121
// because application code should use the components.

‎packages/solid/src/internal.ts‎

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
* entries mark them `@internal` and strip them from their declarations.
2525
* The boundary primitives behind `Errored`, `Loading`, and `Reveal` are
2626
* read back the same way (real on both entries), for renderers that
27-
* build boundaries without the components.
27+
* build boundaries without the components, and so are `sharedConfig`
28+
* (the hydration/SSR coordination object) and the `$DEVCOMP` brand.
2829
*/
2930
import * as core from "solid-js";
3031
import type { Accessor, RevealOrder, ServerErrorHook, ServerErrorSite } from "solid-js";
32+
import type { HydrationContext } from "./server/shared.js";
3133

3234
export {
3335
mergeSources,
@@ -139,3 +141,71 @@ export const createRevealOrder: <T>(
139141
fn: () => T,
140142
options?: { order?: () => RevealOrder; collapsed?: () => boolean }
141143
) => T = core.createRevealOrder;
144+
145+
/**
146+
* The shape `sharedConfig` has on either entry. The two objects share the
147+
* name, not the members: the client's carries hydration state, populated by
148+
* `enableHydration()` and the DOM runtime's `hydrate()`; the server's carries
149+
* the render's `context` and the id allocator. Every member is therefore
150+
* optional — a member is present only on the tier (and, for some, only in
151+
* the phase) that sets it.
152+
*/
153+
interface SharedConfig {
154+
/**
155+
* Both: the next hydration key under the current owner, `undefined` under
156+
* `NoHydration`. Server: always present. Client: assigned by
157+
* `enableHydration()`, read only behind a `hydrating` check.
158+
*/
159+
getNextContextId?: () => string | undefined;
160+
/**
161+
* Both, dev builds only: the id `getNextContextId()` would hand out next,
162+
* read without consuming it (`undefined` outside an id-carrying tree).
163+
* Callers gate on `_SOLID_DEV_`.
164+
*/
165+
devPeekNextContextId?: () => string | undefined;
166+
/** Server: the hydration context of the render in progress, absent outside one. */
167+
context?: HydrationContext;
168+
/** Client: whether a hydration pass is claiming server-rendered DOM right now. */
169+
hydrating?: boolean;
170+
/** Client: whether hydration has completed. */
171+
done?: boolean;
172+
resources?: { [key: string]: any };
173+
/** Client: reads a serialized value by id from the hydration payload. */
174+
load?: (id: string) => Promise<any> | any;
175+
/** Client: whether the hydration payload carries `id`. */
176+
has?: (id: string) => boolean;
177+
/** Client: collects the server-rendered nodes under the hydration root `key` into `registry`. */
178+
gather?: (key: string) => void;
179+
/** Client: the server-rendered nodes of the active root, by hydration key. */
180+
registry?: Map<string, object>;
181+
/**
182+
* Client: the registry/gather pair each streamed boundary registered
183+
* under, keyed by boundary id, so a late resume claims against its own root.
184+
*/
185+
boundaryScopes?: Map<string, { registry?: Map<string, object>; gather?: (key: string) => void }>;
186+
captureBoundaryScope?: (id: string) => void;
187+
cleanupFragment?: (id: string) => void;
188+
loadModuleAssets?: (mapping: Record<string, string>) => Promise<void> | undefined;
189+
completed?: WeakSet<object> | null;
190+
events?: any[] | null;
191+
verifyHydration?: () => void;
192+
/** Client: whether a hydration pass is still claiming — absent means "not hydrating". */
193+
isHydrationInProgress?: () => boolean;
194+
/** Client: runs `callback` once all hydration completes — absent means it already has. */
195+
onHydrationEnd?: (callback: () => void) => void;
196+
/** Client: whether a render under the current owner is part of the claim in progress — absent means "claiming". */
197+
isClaiming?: () => boolean;
198+
}
199+
200+
/**
201+
* The hydration/SSR coordination object the core shares with its renderers
202+
* — the client entry's or the server entry's, whichever the app runs.
203+
*/
204+
export const sharedConfig: SharedConfig = core.sharedConfig;
205+
206+
/**
207+
* Dev builds: the brand the component wrapper sets on every component it
208+
* runs (`Comp[$DEVCOMP] === true`), read by the refresh runtime and
209+
* devtools. Other builds: a symbol nothing sets.
210+
*/
211+
export const $DEVCOMP: symbol = core.$DEVCOMP;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@
3535
* warn once and do nothing.
3636
*/
3737
import {
38-
$DEVCOMP,
3938
createMemo,
4039
createSignal,
4140
getOwner,
4241
onCleanup,
4342
resetErrorHalt,
44-
sharedConfig,
4543
untrack,
4644
DEV
4745
} from "solid-js";
46+
import { $DEVCOMP, sharedConfig } from "solid-js/internal";
4847
import { IS_DEV } from "../client/core.js";
4948
import type { Element as SolidElement } from "../types.js";
5049

0 commit comments

Comments
 (0)