Skip to content

Commit 5bef430

Browse files
ryansolidClaude via Cursorcursoragent
committed
Move boundary primitive types to solid-js/internal (#3709)
`createErrorBoundary`, `createLoadingBoundary` and `createRevealOrder` were tagged `@internal` at their declarations but re-exported from a public block of `solid-js`'s index, so the stripped declarations left dangling re-exports (TS2305 under skipLibCheck: false, `any` otherwise). They move to an `@internal` block of the index: still runtime exports of `solid-js` (so `solid-js/internal` reads them back from the build the app runs), no longer in its public types. `solid-js/internal` declares them with their signatures spelled out for renderer authors. `@solidjs/web`'s frames client and the performance-tracks spec import `createLoadingBoundary` from there. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent ad1ecc5 commit 5bef430

5 files changed

Lines changed: 40 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+
Move `createErrorBoundary`, `createLoadingBoundary` and `createRevealOrder` types to `solid-js/internal`; they remain runtime exports of `solid-js` but are no longer part of its public types (#3709)

‎packages/solid/src/index.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ export {
9999
sharedConfig,
100100
enableHydration,
101101
createRoot,
102-
createErrorBoundary,
103-
createLoadingBoundary,
104-
createRevealOrder,
105102
createMemo,
106103
createSignal,
107104
createStore,
@@ -118,6 +115,15 @@ export {
118115
// module's state, `@internal` so they are stripped from the declarations.
119116
/** @internal */
120117
export { materializeContainerTrace } from "./client/hydration.js";
118+
// The boundary primitives behind `Errored`, `Loading` and `Reveal`: exported
119+
// at runtime (typed for renderers through `solid-js/internal`), `@internal`
120+
// because application code should use the components.
121+
/** @internal */
122+
export {
123+
createErrorBoundary,
124+
createLoadingBoundary,
125+
createRevealOrder
126+
} from "./client/hydration.js";
121127
// Stub exports — only meaningful on the server entry; the client entry
122128
// satisfies the export surface so isomorphic builds don't break.
123129
/** @internal */

‎packages/solid/src/internal.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
* the platform/tier conditions pick the same build the app runs) and
2323
* declared here with their signatures spelled out, because the main
2424
* entries mark them `@internal` and strip them from their declarations.
25+
* The boundary primitives behind `Errored`, `Loading`, and `Reveal` are
26+
* read back the same way (real on both entries), for renderers that
27+
* build boundaries without the components.
2528
*/
2629
import * as core from "solid-js";
27-
import type { ServerErrorHook, ServerErrorSite } from "solid-js";
30+
import type { Accessor, RevealOrder, ServerErrorHook, ServerErrorSite } from "solid-js";
2831

2932
export {
3033
mergeSources,
@@ -117,3 +120,22 @@ export const materializeContainerTrace: (marker: {
117120
$tr: AsyncIterable<any> | { __SEROVAL_STREAM__: true };
118121
$ta?: number;
119122
}) => unknown = core.materializeContainerTrace as any;
123+
124+
/** The primitive behind `<Errored>`: `fn()`, or `fallback(error, reset)` once something under it throws. */
125+
export const createErrorBoundary: <T, U>(
126+
fn: () => T,
127+
fallback: (error: Accessor<unknown>, reset: () => void) => U
128+
) => Accessor<T | U> = core.createErrorBoundary;
129+
130+
/** The primitive behind `<Loading>`: `fallback()` while async reads under `fn` are pending, else `fn()`. */
131+
export const createLoadingBoundary: <T, U>(
132+
fn: () => T,
133+
fallback: () => U,
134+
options?: { on?: () => any }
135+
) => Accessor<T | U> = core.createLoadingBoundary;
136+
137+
/** The primitive behind `<Reveal>`: coordinates when the loading boundaries under `fn` reveal. */
138+
export const createRevealOrder: <T>(
139+
fn: () => T,
140+
options?: { order?: () => RevealOrder; collapsed?: () => boolean }
141+
) => T = core.createRevealOrder;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// state survive (policy A).
1818

1919
import {
20-
createLoadingBoundary,
2120
createMemo,
2221
createOwner,
2322
createRenderEffect,
@@ -51,7 +50,7 @@ import {
5150
reviveContainerTraces,
5251
setContainerTraceMaterializer
5352
} from "./frame-container-plugin.js";
54-
import { materializeContainerTrace } from "solid-js/internal";
53+
import { createLoadingBoundary, materializeContainerTrace } from "solid-js/internal";
5554

5655
setContainerTraceMaterializer(materializeContainerTrace);
5756

‎packages/web/test/performance-tracks.spec.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import {
2525
OBSERVE,
2626
Show,
2727
createEffect,
28-
createLoadingBoundary,
2928
createMemo,
3029
createRenderEffect,
3130
createRoot,
3231
createSignal,
3332
flush
3433
} from "solid-js";
3534
import type { RecordListener, RecordLive, RecordType } from "solid-js";
35+
import { createLoadingBoundary } from "solid-js/internal";
3636
import { attribution, formatOrigin, formatRerun } from "solid-js/attribution";
3737
import type { InteractionEvent, RerunEvent, HoldEvent } from "solid-js/attribution";
3838
import type { CallEvent } from "@solidjs/web";

0 commit comments

Comments
 (0)