MCPcopy Create free account
hub / github.com/solidjs/solid-start / wrapper

Function wrapper

packages/start/src/shared/lazy.ts:20–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19const withAssets = function <T extends () => Promise<{ default: Component<any> }>>(fn: T): T {
20 const wrapper = async () => {
21 const mod = await fn();
22
23 // This id$$ export is generated by the lazy vite plugin
24 const id: string = (mod as any).id$$;
25 if (!id) return mod;
26
27 if (!mod.default) {
28 console.error(`Module ${id} does not export default`);
29 return { default: () => [] };
30 }
31
32 const assets: Asset[] = await getAssets(id);
33 if (!assets.length) return mod;
34
35 return {
36 default: (props: any) => {
37 const { nonce } = getRequestEvent() as PageEvent;
38 useAssets(assets, nonce);
39
40 return mod.default(props);
41 },
42 };
43 };
44
45 return wrapper as T;
46};

Callers

nothing calls this directly

Calls 3

useAssetsFunction · 0.90
fnFunction · 0.85
getAssetsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…