Skip to content

Commit 284738e

Browse files
committed
Loading boundary enforcement, enableExternalSource, SSR hydration fixes, rename createLoadBoundary
- Throw on async content without <Loading> boundary during render() - Re-export enableExternalSource and types from @solidjs/signals - Add `on` prop to <Loading> for declarative boundary reset - Fix ssrSource "client" and "hybrid" mode hydration for projections/stores - Rename createLoadBoundary to createLoadingBoundary - Update strict read warning test assertions to match new message format - Bump @solidjs/signals peer dependency Made-with: Cursor
1 parent 0e27e61 commit 284738e

22 files changed

Lines changed: 464 additions & 224 deletions

‎.changeset/dev-warn-unhandled-async.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"solid-js": patch
33
---
44

5-
Add dev-mode error when async content is used in JSX without a `<Loading>` boundary during `render()`. In dev, the app is unmounted and an error message is rendered into the container. Re-export `setOnUnhandledAsync` hook from `@solidjs/signals`.
5+
Add dev-mode enforcement of Loading boundaries for async content. During `render()`, async values consumed by JSX without a `<Loading>` boundary now throw an error catchable by `<Errored>` boundaries. Re-export `enforceLoadingBoundary` from `@solidjs/signals`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
Re-export `enableExternalSource` and related types from `@solidjs/signals`. Add `on` prop to `<Loading>` component for declarative boundary reset.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
Fix ssrSource "client" and "hybrid" mode hydration for projections and stores
6+
7+
- "client" mode: use a `hydrated` signal gate so the user's function runs only after hydration completes, instead of returning an identity function that never transitions
8+
- "hybrid" mode: use a `hydrated` signal gate to load the server promise during hydration, then transition to the client's async generator post-hydration. A shallow shadow draft absorbs the first iteration's reads/writes (preventing first-value duplication) before switching to the real reactive store
9+
- Fix microtask timing in `hydrateStoreFromAsyncIterable` with a custom thenable so `process` and `asyncWrite` execute in the same microtask
10+
- Skip hydration wrapper for transparent memos (HMR support)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
Rename `createLoadBoundary` to `createLoadingBoundary` for consistency with the `<Loading>` component naming.

‎.cursor/rules/architecture.mdc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ All reactivity comes from `@solidjs/signals`:
5555

5656
## Flow Controls
5757

58-
Built on signals primitives: `For` (mapArray), `Repeat` (repeat), `Show` (createMemo), `Switch/Match` (children + memos), `Errored` (createErrorBoundary), `Boundary` (createBoundary), `Loading` (createLoadBoundary).
58+
Built on signals primitives: `For` (mapArray), `Repeat` (repeat), `Show` (createMemo), `Switch/Match` (children + memos), `Errored` (createErrorBoundary), `Boundary` (createBoundary), `Loading` (createLoadingBoundary).
5959

6060
All support `keyed` mode (identity comparison) vs non-keyed (truthiness). Function children in `Show`/`Match` receive narrowed accessors with stale-read protection.
6161

‎.cursor/rules/solid-core.mdc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Function children in `Show`/`Match` have stale-read protection — accessing aft
5151

5252
`sharedConfig` coordinates hydration state: `hydrating`, `resources`, `load`, `has`, `gather`, `registry`, `done`, `getNextContextId()`.
5353

54-
`Loading` component uses `createLoadBoundary()` normally. During hydration, it checks resources via `sharedConfig.has(id)` and `sharedConfig.load(id)`, managing promise resolution.
54+
`Loading` component uses `createLoadingBoundary()` normally. During hydration, it checks resources via `sharedConfig.has(id)` and `sharedConfig.load(id)`, managing promise resolution.
5555

5656
## Server Stubs
5757

‎examples/ssr/stream/rollup.config.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ export default [
7070
],
7171
preserveEntrySignatures: false,
7272
plugins: [
73-
nodeResolve({ exportConditions: ["solid"] }),
73+
nodeResolve({ exportConditions: ["solid", "development"] }),
7474
babel({
7575
babelHelpers: "bundled",
76-
presets: [["solid", { generate: "dom", hydratable: true }]]
76+
presets: [["solid", { generate: "dom", hydratable: true, dev: true }]]
7777
}),
7878
common(),
7979
solidAssetManifest(),

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"tsconfig-replace-paths": "^0.0.11",
5656
"turbo": "^2.0.0",
5757
"typescript": "~5.7.2",
58-
"vite-plugin-solid": "^2.6.1",
58+
"vite-plugin-solid": "3.0.0.next.2",
5959
"vitest": "^2.1.2"
6060
},
6161
"simple-git-hooks": {

‎packages/solid-web/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
},
9292
"peerDependencies": {
9393
"solid-js": "^2.0.0-beta.2",
94-
"@solidjs/signals": "^0.12.0"
94+
"@solidjs/signals": "^0.13.0"
9595
},
9696
"devDependencies": {
9797
"solid-js": "workspace:*"

‎packages/solid-web/src/index.ts‎

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
JSX,
1414
sharedConfig,
1515
enableHydration,
16-
setOnUnhandledAsync,
16+
enforceLoadingBoundary,
1717
$DEVCOMP,
1818
ComponentProps,
1919
ValidComponent,
@@ -23,35 +23,11 @@ import {
2323
export * from "./client.js";
2424

2525
export function render(...args: Parameters<typeof renderCore>): ReturnType<typeof renderCore> {
26-
let unhandledAsync = false;
2726
// @ts-ignore — replaced at build time
28-
if ("_DX_DEV_") {
29-
setOnUnhandledAsync(() => {
30-
unhandledAsync = true;
31-
});
32-
}
27+
if ("_DX_DEV_") enforceLoadingBoundary(true);
3328
const result = renderCore(...args);
3429
// @ts-ignore — replaced at build time
35-
if ("_DX_DEV_") {
36-
setOnUnhandledAsync(null);
37-
if (unhandledAsync) {
38-
const message =
39-
"Async content was used in JSX without a <Loading> boundary. " +
40-
"Wrap async content in <Loading> to show a fallback while loading.";
41-
result();
42-
const container = args[1] as Element;
43-
container.textContent = "";
44-
const msg = document.createElement("pre");
45-
msg.style.cssText =
46-
"color:#e53e3e;background:#fff5f5;border:2px solid #e53e3e;" +
47-
"border-radius:4px;padding:16px;margin:16px;font-family:monospace;" +
48-
"white-space:pre-wrap;word-break:break-word;";
49-
msg.textContent = message;
50-
container.appendChild(msg);
51-
console.error(message);
52-
return () => {};
53-
}
54-
}
30+
if ("_DX_DEV_") enforceLoadingBoundary(false);
5531
return result;
5632
}
5733

0 commit comments

Comments
 (0)