+1
-1
@@ -664,3 +664,3 @@ # Solid 2.0 — Cheatsheet | ||
| - [`MIGRATION.md`](https://github.com/solidjs/solid/blob/main/documentation/solid-2.0/MIGRATION.md) — full beta-tester migration guide. | ||
| - [`MIGRATION.md`](https://github.com/solidjs/solid/blob/main/documentation/solid-2.0/MIGRATION.md) — full migration guide. | ||
| - [Solid 2.0 RFCs](https://github.com/solidjs/solid/tree/main/documentation/solid-2.0) — deep-dive design docs by subsystem. |
+50
-12
@@ -149,2 +149,3 @@ 'use strict'; | ||
| } | ||
| if (result && typeof result.then === "function") result.then(undefined, () => {}); | ||
| return result; | ||
@@ -169,3 +170,6 @@ } finally { | ||
| }; | ||
| if (initP.s === 2) throw initP.v; | ||
| if (initP.s === 2) { | ||
| if (typeof initP.then === "function") initP.then(undefined, () => {}); | ||
| throw initP.v; | ||
| } | ||
| if (initP.s === 1) return initP.v; | ||
@@ -183,2 +187,15 @@ } | ||
| }; | ||
| const LIVE_SOURCE = Symbol.for("solid.LiveSource"); | ||
| let liveGate; | ||
| function armLiveTakeover() { | ||
| if (!liveGate) { | ||
| const [read, write] = signals.createSignal(false); | ||
| liveGate = read; | ||
| onHydrationEnd(() => { | ||
| liveGate = undefined; | ||
| write(true); | ||
| }); | ||
| } | ||
| liveGate(); | ||
| } | ||
| function hasLoadingWindow(options) { | ||
@@ -489,3 +506,10 @@ return options != null && typeof options === "object" && ("loadingValue" in options || options.seedLoadingValue === true); | ||
| if (aiResult !== null) return aiResult; | ||
| return coreFn(prev => readSerializedOrCompute(fn, prev, options), options); | ||
| return coreFn(prev => { | ||
| const o = signals.getOwner(); | ||
| if (sharedConfig.done || !sharedConfig.has(o.id)) return fn(prev); | ||
| let traced; | ||
| const value = readHydratedValue(sharedConfig.load(o.id), () => traced = subFetch(fn, prev), options); | ||
| if (traced != null && traced[LIVE_SOURCE]) armLiveTakeover(); | ||
| return value; | ||
| }, options); | ||
| } | ||
@@ -579,7 +603,11 @@ function hydratedCreateMemo(compute, options) { | ||
| } | ||
| function lazyHydrationLookup(comp, moduleUrl) { | ||
| function lazyHydrationLookup(comp, moduleUrl, exportName) { | ||
| const o = signals.getOwner(); | ||
| const key = o && o.id != null ? signals.peekNextChildId(o) : undefined; | ||
| const cached = key != null ? globalThis._$HY?.modules?.[key] : undefined; | ||
| if (cached) return () => cached.default; | ||
| if (cached) { | ||
| const component = exportName ? cached[exportName] : cached.default; | ||
| if (typeof component !== "function") throw new Error(`lazy() (hydration id "${key}") preloaded a module whose "${exportName ?? "default"}" ` + "export is not a component. lazy() hydrates synchronously from the preloaded " + "module; select a named export with the { export } option, or re-export the " + "component as the module's default. Wrappers that pick an export at runtime " + "inside the import thunk are not supported."); | ||
| return () => component; | ||
| } | ||
| if (!comp && moduleUrl) { | ||
@@ -992,14 +1020,24 @@ throw new Error(`lazy() module "${moduleUrl}" (hydration id "${key}") was not preloaded before ` + "hydration. Ensure it is inside a Loading boundary."); | ||
| } | ||
| function lazy(fn, moduleUrl) { | ||
| function lazy(fn, options, moduleUrl) { | ||
| const exportName = options?.export; | ||
| if (typeof options === "string") throw new Error("lazy() moduleUrl moved to the third argument: lazy(fn, options?, moduleUrl?). " + "Pass { export } options second, or undefined."); | ||
| let comp; | ||
| let p; | ||
| const load = () => { | ||
| if (p) return p; | ||
| const cur = p = fn(); | ||
| cur.then(mod => { | ||
| comp = () => exportName ? mod[exportName] : mod.default; | ||
| }, | ||
| () => { | ||
| if (p === cur) p = undefined; | ||
| }); | ||
| return cur; | ||
| }; | ||
| const wrap = props => { | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl); | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl, exportName); | ||
| let local = comp; | ||
| if (!local) { | ||
| p || (p = fn()); | ||
| p.then(mod => { | ||
| comp = () => mod.default; | ||
| }); | ||
| local = signals.createMemo(() => p.then(mod => mod.default)); | ||
| load(); | ||
| local = signals.createMemo(() => load().then(mod => exportName ? mod[exportName] : mod.default)); | ||
| } | ||
@@ -1016,3 +1054,3 @@ let Comp; | ||
| }; | ||
| wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p); | ||
| wrap.preload = load; | ||
| wrap.moduleUrl = moduleUrl; | ||
@@ -1019,0 +1057,0 @@ return wrap; |
+50
-12
@@ -148,2 +148,3 @@ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, untrack, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createRevealOrder as createRevealOrder$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, peekNextChildId, getNextChildId, clearSnapshots, flush, markSnapshotScope, onCleanup, isDisposed, mapArray, repeat, DEV as DEV$1 } from '@solidjs/signals'; | ||
| } | ||
| if (result && typeof result.then === "function") result.then(undefined, () => {}); | ||
| return result; | ||
@@ -168,3 +169,6 @@ } finally { | ||
| }; | ||
| if (initP.s === 2) throw initP.v; | ||
| if (initP.s === 2) { | ||
| if (typeof initP.then === "function") initP.then(undefined, () => {}); | ||
| throw initP.v; | ||
| } | ||
| if (initP.s === 1) return initP.v; | ||
@@ -182,2 +186,15 @@ } | ||
| }; | ||
| const LIVE_SOURCE = Symbol.for("solid.LiveSource"); | ||
| let liveGate; | ||
| function armLiveTakeover() { | ||
| if (!liveGate) { | ||
| const [read, write] = createSignal$1(false); | ||
| liveGate = read; | ||
| onHydrationEnd(() => { | ||
| liveGate = undefined; | ||
| write(true); | ||
| }); | ||
| } | ||
| liveGate(); | ||
| } | ||
| function hasLoadingWindow(options) { | ||
@@ -488,3 +505,10 @@ return options != null && typeof options === "object" && ("loadingValue" in options || options.seedLoadingValue === true); | ||
| if (aiResult !== null) return aiResult; | ||
| return coreFn(prev => readSerializedOrCompute(fn, prev, options), options); | ||
| return coreFn(prev => { | ||
| const o = getOwner(); | ||
| if (sharedConfig.done || !sharedConfig.has(o.id)) return fn(prev); | ||
| let traced; | ||
| const value = readHydratedValue(sharedConfig.load(o.id), () => traced = subFetch(fn, prev), options); | ||
| if (traced != null && traced[LIVE_SOURCE]) armLiveTakeover(); | ||
| return value; | ||
| }, options); | ||
| } | ||
@@ -578,7 +602,11 @@ function hydratedCreateMemo(compute, options) { | ||
| } | ||
| function lazyHydrationLookup(comp, moduleUrl) { | ||
| function lazyHydrationLookup(comp, moduleUrl, exportName) { | ||
| const o = getOwner(); | ||
| const key = o && o.id != null ? peekNextChildId(o) : undefined; | ||
| const cached = key != null ? globalThis._$HY?.modules?.[key] : undefined; | ||
| if (cached) return () => cached.default; | ||
| if (cached) { | ||
| const component = exportName ? cached[exportName] : cached.default; | ||
| if (typeof component !== "function") throw new Error(`lazy() (hydration id "${key}") preloaded a module whose "${exportName ?? "default"}" ` + "export is not a component. lazy() hydrates synchronously from the preloaded " + "module; select a named export with the { export } option, or re-export the " + "component as the module's default. Wrappers that pick an export at runtime " + "inside the import thunk are not supported."); | ||
| return () => component; | ||
| } | ||
| if (!comp && moduleUrl) { | ||
@@ -991,14 +1019,24 @@ throw new Error(`lazy() module "${moduleUrl}" (hydration id "${key}") was not preloaded before ` + "hydration. Ensure it is inside a Loading boundary."); | ||
| } | ||
| function lazy(fn, moduleUrl) { | ||
| function lazy(fn, options, moduleUrl) { | ||
| const exportName = options?.export; | ||
| if (typeof options === "string") throw new Error("lazy() moduleUrl moved to the third argument: lazy(fn, options?, moduleUrl?). " + "Pass { export } options second, or undefined."); | ||
| let comp; | ||
| let p; | ||
| const load = () => { | ||
| if (p) return p; | ||
| const cur = p = fn(); | ||
| cur.then(mod => { | ||
| comp = () => exportName ? mod[exportName] : mod.default; | ||
| }, | ||
| () => { | ||
| if (p === cur) p = undefined; | ||
| }); | ||
| return cur; | ||
| }; | ||
| const wrap = props => { | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl); | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl, exportName); | ||
| let local = comp; | ||
| if (!local) { | ||
| p || (p = fn()); | ||
| p.then(mod => { | ||
| comp = () => mod.default; | ||
| }); | ||
| local = createMemo$1(() => p.then(mod => mod.default)); | ||
| load(); | ||
| local = createMemo$1(() => load().then(mod => exportName ? mod[exportName] : mod.default)); | ||
| } | ||
@@ -1015,3 +1053,3 @@ let Comp; | ||
| }; | ||
| wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p); | ||
| wrap.preload = load; | ||
| wrap.moduleUrl = moduleUrl; | ||
@@ -1018,0 +1056,0 @@ return wrap; |
+48
-12
@@ -132,2 +132,3 @@ 'use strict'; | ||
| } | ||
| if (result && typeof result.then === "function") result.then(undefined, () => {}); | ||
| return result; | ||
@@ -152,3 +153,6 @@ } finally { | ||
| }; | ||
| if (initP.s === 2) throw initP.v; | ||
| if (initP.s === 2) { | ||
| if (typeof initP.then === "function") initP.then(undefined, () => {}); | ||
| throw initP.v; | ||
| } | ||
| if (initP.s === 1) return initP.v; | ||
@@ -166,2 +170,15 @@ } | ||
| }; | ||
| const LIVE_SOURCE = Symbol.for("solid.LiveSource"); | ||
| let liveGate; | ||
| function armLiveTakeover() { | ||
| if (!liveGate) { | ||
| const [read, write] = signals.createSignal(false); | ||
| liveGate = read; | ||
| onHydrationEnd(() => { | ||
| liveGate = undefined; | ||
| write(true); | ||
| }); | ||
| } | ||
| liveGate(); | ||
| } | ||
| function hasLoadingWindow(options) { | ||
@@ -472,3 +489,10 @@ return options != null && typeof options === "object" && ("loadingValue" in options || options.seedLoadingValue === true); | ||
| if (aiResult !== null) return aiResult; | ||
| return coreFn(prev => readSerializedOrCompute(fn, prev, options), options); | ||
| return coreFn(prev => { | ||
| const o = signals.getOwner(); | ||
| if (sharedConfig.done || !sharedConfig.has(o.id)) return fn(prev); | ||
| let traced; | ||
| const value = readHydratedValue(sharedConfig.load(o.id), () => traced = subFetch(fn, prev), options); | ||
| if (traced != null && traced[LIVE_SOURCE]) armLiveTakeover(); | ||
| return value; | ||
| }, options); | ||
| } | ||
@@ -562,7 +586,10 @@ function hydratedCreateMemo(compute, options) { | ||
| } | ||
| function lazyHydrationLookup(comp, moduleUrl) { | ||
| function lazyHydrationLookup(comp, moduleUrl, exportName) { | ||
| const o = signals.getOwner(); | ||
| const key = o && o.id != null ? signals.peekNextChildId(o) : undefined; | ||
| const cached = key != null ? globalThis._$HY?.modules?.[key] : undefined; | ||
| if (cached) return () => cached.default; | ||
| if (cached) { | ||
| const component = exportName ? cached[exportName] : cached.default; | ||
| return () => component; | ||
| } | ||
| if (!comp && moduleUrl) { | ||
@@ -975,14 +1002,23 @@ throw new Error(`lazy() module "${moduleUrl}" (hydration id "${key}") was not preloaded before ` + "hydration. Ensure it is inside a Loading boundary."); | ||
| } | ||
| function lazy(fn, moduleUrl) { | ||
| function lazy(fn, options, moduleUrl) { | ||
| const exportName = options?.export; | ||
| let comp; | ||
| let p; | ||
| const load = () => { | ||
| if (p) return p; | ||
| const cur = p = fn(); | ||
| cur.then(mod => { | ||
| comp = () => exportName ? mod[exportName] : mod.default; | ||
| }, | ||
| () => { | ||
| if (p === cur) p = undefined; | ||
| }); | ||
| return cur; | ||
| }; | ||
| const wrap = props => { | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl); | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl, exportName); | ||
| let local = comp; | ||
| if (!local) { | ||
| p || (p = fn()); | ||
| p.then(mod => { | ||
| comp = () => mod.default; | ||
| }); | ||
| local = signals.createMemo(() => p.then(mod => mod.default)); | ||
| load(); | ||
| local = signals.createMemo(() => load().then(mod => exportName ? mod[exportName] : mod.default)); | ||
| } | ||
@@ -996,3 +1032,3 @@ let Comp; | ||
| }; | ||
| wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p); | ||
| wrap.preload = load; | ||
| wrap.moduleUrl = moduleUrl; | ||
@@ -999,0 +1035,0 @@ return wrap; |
+48
-12
@@ -131,2 +131,3 @@ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createRevealOrder as createRevealOrder$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getOwner, peekNextChildId, getNextChildId, clearSnapshots, flush, markSnapshotScope, onCleanup, isDisposed, untrack, mapArray, repeat } from '@solidjs/signals'; | ||
| } | ||
| if (result && typeof result.then === "function") result.then(undefined, () => {}); | ||
| return result; | ||
@@ -151,3 +152,6 @@ } finally { | ||
| }; | ||
| if (initP.s === 2) throw initP.v; | ||
| if (initP.s === 2) { | ||
| if (typeof initP.then === "function") initP.then(undefined, () => {}); | ||
| throw initP.v; | ||
| } | ||
| if (initP.s === 1) return initP.v; | ||
@@ -165,2 +169,15 @@ } | ||
| }; | ||
| const LIVE_SOURCE = Symbol.for("solid.LiveSource"); | ||
| let liveGate; | ||
| function armLiveTakeover() { | ||
| if (!liveGate) { | ||
| const [read, write] = createSignal$1(false); | ||
| liveGate = read; | ||
| onHydrationEnd(() => { | ||
| liveGate = undefined; | ||
| write(true); | ||
| }); | ||
| } | ||
| liveGate(); | ||
| } | ||
| function hasLoadingWindow(options) { | ||
@@ -471,3 +488,10 @@ return options != null && typeof options === "object" && ("loadingValue" in options || options.seedLoadingValue === true); | ||
| if (aiResult !== null) return aiResult; | ||
| return coreFn(prev => readSerializedOrCompute(fn, prev, options), options); | ||
| return coreFn(prev => { | ||
| const o = getOwner(); | ||
| if (sharedConfig.done || !sharedConfig.has(o.id)) return fn(prev); | ||
| let traced; | ||
| const value = readHydratedValue(sharedConfig.load(o.id), () => traced = subFetch(fn, prev), options); | ||
| if (traced != null && traced[LIVE_SOURCE]) armLiveTakeover(); | ||
| return value; | ||
| }, options); | ||
| } | ||
@@ -561,7 +585,10 @@ function hydratedCreateMemo(compute, options) { | ||
| } | ||
| function lazyHydrationLookup(comp, moduleUrl) { | ||
| function lazyHydrationLookup(comp, moduleUrl, exportName) { | ||
| const o = getOwner(); | ||
| const key = o && o.id != null ? peekNextChildId(o) : undefined; | ||
| const cached = key != null ? globalThis._$HY?.modules?.[key] : undefined; | ||
| if (cached) return () => cached.default; | ||
| if (cached) { | ||
| const component = exportName ? cached[exportName] : cached.default; | ||
| return () => component; | ||
| } | ||
| if (!comp && moduleUrl) { | ||
@@ -974,14 +1001,23 @@ throw new Error(`lazy() module "${moduleUrl}" (hydration id "${key}") was not preloaded before ` + "hydration. Ensure it is inside a Loading boundary."); | ||
| } | ||
| function lazy(fn, moduleUrl) { | ||
| function lazy(fn, options, moduleUrl) { | ||
| const exportName = options?.export; | ||
| let comp; | ||
| let p; | ||
| const load = () => { | ||
| if (p) return p; | ||
| const cur = p = fn(); | ||
| cur.then(mod => { | ||
| comp = () => exportName ? mod[exportName] : mod.default; | ||
| }, | ||
| () => { | ||
| if (p === cur) p = undefined; | ||
| }); | ||
| return cur; | ||
| }; | ||
| const wrap = props => { | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl); | ||
| if (sharedConfig.hydrating) comp = _lazyHydrationLookup(comp, moduleUrl, exportName); | ||
| let local = comp; | ||
| if (!local) { | ||
| p || (p = fn()); | ||
| p.then(mod => { | ||
| comp = () => mod.default; | ||
| }); | ||
| local = createMemo$1(() => p.then(mod => mod.default)); | ||
| load(); | ||
| local = createMemo$1(() => load().then(mod => exportName ? mod[exportName] : mod.default)); | ||
| } | ||
@@ -995,3 +1031,3 @@ let Comp; | ||
| }; | ||
| wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p); | ||
| wrap.preload = load; | ||
| wrap.moduleUrl = moduleUrl; | ||
@@ -998,0 +1034,0 @@ return wrap; |
+2
-2
| { | ||
| "name": "solid-js", | ||
| "description": "Reactive JavaScript library for building user interfaces. Compiles JSX to real DOM with fine-grained signal-based updates — no virtual DOM.", | ||
| "version": "2.0.0-rc.0", | ||
| "version": "2.0.0-rc.1", | ||
| "author": "Ryan Carniato", | ||
@@ -131,3 +131,3 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@solidjs/signals": "^2.0.0-rc.0", | ||
| "@solidjs/signals": "^2.0.0-rc.1", | ||
| "csstype": "^3.1.0", | ||
@@ -134,0 +134,0 @@ "seroval": "~1.5.4", |
+1
-1
@@ -11,3 +11,3 @@ <p> | ||
| > **You are looking at Solid 2.0 (experimental beta).** | ||
| > **You are looking at Solid 2.0 (Release Candidate).** | ||
| > Public surface differs from 1.x — split-phase `createEffect`, microtask batching, `Loading`/`Errored` boundaries, draft-first store setters, async-in-computations, removed `solid-js/web` and `solid-js/store` subpaths, and more. | ||
@@ -14,0 +14,0 @@ > |
@@ -74,3 +74,11 @@ import type { Element as SolidElement } from "../types.cjs"; | ||
| * | ||
| * @param fn dynamic import returning the module's default export | ||
| * @param fn dynamic import resolving the component's module. By default the | ||
| * component must BE the module's default export (same contract as | ||
| * React.lazy): hydration resolves it synchronously from the preloaded | ||
| * module, so wrappers that select a named export at runtime are not | ||
| * supported. To use a named export, pass `{ export: "Name" }` — the name is | ||
| * a call-site literal available on both server and client, so the | ||
| * synchronous hydration claim is preserved. | ||
| * @param options `{ export?: string }` — which export of the resolved module | ||
| * is the component (defaults to `"default"`). | ||
| * @param moduleUrl optional module specifier injected by the bundler | ||
@@ -85,2 +93,3 @@ * integration; exposed as the component's `moduleUrl` property (islands) | ||
| * const Profile = lazy(() => import("./Profile")); | ||
| * const About = lazy(() => import("./pages"), { export: "About" }); | ||
| * | ||
@@ -99,5 +108,13 @@ * function App() { | ||
| */ | ||
| export declare function lazy<M extends Record<string, any>, K extends keyof M & string>(fn: () => Promise<M>, options: { | ||
| export: K; | ||
| }, moduleUrl?: string): M[K] & { | ||
| preload: () => Promise<M>; | ||
| moduleUrl?: string; | ||
| }; | ||
| export declare function lazy<T extends Component<any>>(fn: () => Promise<{ | ||
| default: T; | ||
| }>, moduleUrl?: string): T & { | ||
| }>, options?: { | ||
| export?: string; | ||
| }, moduleUrl?: string): T & { | ||
| preload: () => Promise<{ | ||
@@ -104,0 +121,0 @@ default: T; |
@@ -139,3 +139,3 @@ import { createRenderEffect as coreRenderEffect, createEffect as coreEffect, type Accessor, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Refreshable, type Signal, type SignalOptions, type SourceAccessor, type Store, type StoreSetter, type RevealOrder, type Context } from "@solidjs/signals"; | ||
| export declare const sharedConfig: SharedConfig; | ||
| export declare let _lazyHydrationLookup: (<T>(comp: (() => T | undefined) | undefined, moduleUrl?: string) => (() => T) | undefined) | undefined; | ||
| export declare let _lazyHydrationLookup: (<T>(comp: (() => T | undefined) | undefined, moduleUrl?: string, exportName?: string) => (() => T) | undefined) | undefined; | ||
| /** | ||
@@ -142,0 +142,0 @@ * Materialize a container TRACE — snapshot then patch batches, the |
@@ -56,8 +56,13 @@ import type { Element as SolidElement } from "../types.cjs"; | ||
| * scopes the owner so hydration IDs align with the client's createMemo in lazy(). | ||
| * The bundler plugin injects `moduleUrl` (the module specifier) so the server | ||
| * can look up client chunk URLs from the asset manifest. When no callsite | ||
| * `moduleUrl` exists (e.g. `lazy` over an `import.meta.glob` entry), asset | ||
| * resolution defers until the import resolves and reads the module's | ||
| * bundler-injected `$$moduleUrl` export instead. | ||
| * The component is the resolved module's default export, or the export named | ||
| * by the `{ export }` option (a call-site literal, so the client half can | ||
| * resolve the same export synchronously during hydration). | ||
| * | ||
| * The bundler plugin injects `moduleUrl` (the module specifier, third | ||
| * argument) so the server can look up client chunk URLs from the asset | ||
| * manifest. When no callsite `moduleUrl` exists (e.g. `lazy` over an | ||
| * `import.meta.glob` entry), asset resolution defers until the import | ||
| * resolves and reads the module's bundler-injected `$$moduleUrl` export | ||
| * instead. | ||
| * | ||
| * The returned component's `moduleUrl` property resolves through the active | ||
@@ -71,5 +76,13 @@ * request's asset manifest: inside SSR it returns the client-loadable entry | ||
| */ | ||
| export declare function lazy<M extends Record<string, any>, K extends keyof M & string>(fn: () => Promise<M>, options: { | ||
| export: K; | ||
| }, moduleUrl?: string): M[K] & { | ||
| preload: () => Promise<M>; | ||
| moduleUrl?: string; | ||
| }; | ||
| export declare function lazy<T extends Component<any>>(fn: () => Promise<{ | ||
| default: T; | ||
| }>, moduleUrl?: string): T & { | ||
| }>, options?: { | ||
| export?: string; | ||
| }, moduleUrl?: string): T & { | ||
| preload: () => Promise<{ | ||
@@ -76,0 +89,0 @@ default: T; |
@@ -74,3 +74,11 @@ import type { Element as SolidElement } from "../types.js"; | ||
| * | ||
| * @param fn dynamic import returning the module's default export | ||
| * @param fn dynamic import resolving the component's module. By default the | ||
| * component must BE the module's default export (same contract as | ||
| * React.lazy): hydration resolves it synchronously from the preloaded | ||
| * module, so wrappers that select a named export at runtime are not | ||
| * supported. To use a named export, pass `{ export: "Name" }` — the name is | ||
| * a call-site literal available on both server and client, so the | ||
| * synchronous hydration claim is preserved. | ||
| * @param options `{ export?: string }` — which export of the resolved module | ||
| * is the component (defaults to `"default"`). | ||
| * @param moduleUrl optional module specifier injected by the bundler | ||
@@ -85,2 +93,3 @@ * integration; exposed as the component's `moduleUrl` property (islands) | ||
| * const Profile = lazy(() => import("./Profile")); | ||
| * const About = lazy(() => import("./pages"), { export: "About" }); | ||
| * | ||
@@ -99,5 +108,13 @@ * function App() { | ||
| */ | ||
| export declare function lazy<M extends Record<string, any>, K extends keyof M & string>(fn: () => Promise<M>, options: { | ||
| export: K; | ||
| }, moduleUrl?: string): M[K] & { | ||
| preload: () => Promise<M>; | ||
| moduleUrl?: string; | ||
| }; | ||
| export declare function lazy<T extends Component<any>>(fn: () => Promise<{ | ||
| default: T; | ||
| }>, moduleUrl?: string): T & { | ||
| }>, options?: { | ||
| export?: string; | ||
| }, moduleUrl?: string): T & { | ||
| preload: () => Promise<{ | ||
@@ -104,0 +121,0 @@ default: T; |
@@ -139,3 +139,3 @@ import { createRenderEffect as coreRenderEffect, createEffect as coreEffect, type Accessor, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Refreshable, type Signal, type SignalOptions, type SourceAccessor, type Store, type StoreSetter, type RevealOrder, type Context } from "@solidjs/signals"; | ||
| export declare const sharedConfig: SharedConfig; | ||
| export declare let _lazyHydrationLookup: (<T>(comp: (() => T | undefined) | undefined, moduleUrl?: string) => (() => T) | undefined) | undefined; | ||
| export declare let _lazyHydrationLookup: (<T>(comp: (() => T | undefined) | undefined, moduleUrl?: string, exportName?: string) => (() => T) | undefined) | undefined; | ||
| /** | ||
@@ -142,0 +142,0 @@ * Materialize a container TRACE — snapshot then patch batches, the |
@@ -56,8 +56,13 @@ import type { Element as SolidElement } from "../types.js"; | ||
| * scopes the owner so hydration IDs align with the client's createMemo in lazy(). | ||
| * The bundler plugin injects `moduleUrl` (the module specifier) so the server | ||
| * can look up client chunk URLs from the asset manifest. When no callsite | ||
| * `moduleUrl` exists (e.g. `lazy` over an `import.meta.glob` entry), asset | ||
| * resolution defers until the import resolves and reads the module's | ||
| * bundler-injected `$$moduleUrl` export instead. | ||
| * The component is the resolved module's default export, or the export named | ||
| * by the `{ export }` option (a call-site literal, so the client half can | ||
| * resolve the same export synchronously during hydration). | ||
| * | ||
| * The bundler plugin injects `moduleUrl` (the module specifier, third | ||
| * argument) so the server can look up client chunk URLs from the asset | ||
| * manifest. When no callsite `moduleUrl` exists (e.g. `lazy` over an | ||
| * `import.meta.glob` entry), asset resolution defers until the import | ||
| * resolves and reads the module's bundler-injected `$$moduleUrl` export | ||
| * instead. | ||
| * | ||
| * The returned component's `moduleUrl` property resolves through the active | ||
@@ -71,5 +76,13 @@ * request's asset manifest: inside SSR it returns the client-loadable entry | ||
| */ | ||
| export declare function lazy<M extends Record<string, any>, K extends keyof M & string>(fn: () => Promise<M>, options: { | ||
| export: K; | ||
| }, moduleUrl?: string): M[K] & { | ||
| preload: () => Promise<M>; | ||
| moduleUrl?: string; | ||
| }; | ||
| export declare function lazy<T extends Component<any>>(fn: () => Promise<{ | ||
| default: T; | ||
| }>, moduleUrl?: string): T & { | ||
| }>, options?: { | ||
| export?: string; | ||
| }, moduleUrl?: string): T & { | ||
| preload: () => Promise<{ | ||
@@ -76,0 +89,0 @@ default: T; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
529017
3.24%11937
4.03%12
-7.69%Updated