Home / Function/ check() — astro Function Reference

check() — astro Function Reference

Architecture documentation for the check() function in server.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  a8b24013_5808_2b5b_68c5_f9dd75dd5940["check()"]
  8026f0af_f709_2aa5_9cc2_85bfe4d5b6b2["server.ts"]
  a8b24013_5808_2b5b_68c5_f9dd75dd5940 -->|defined in| 8026f0af_f709_2aa5_9cc2_85bfe4d5b6b2
  e4501448_473f_08e1_06ae_582762dd666d["renderToStaticMarkup()"]
  e4501448_473f_08e1_06ae_582762dd666d -->|calls| a8b24013_5808_2b5b_68c5_f9dd75dd5940
  style a8b24013_5808_2b5b_68c5_f9dd75dd5940 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/solid/src/server.ts lines 18–47

async function check(
	this: RendererContext,
	Component: any,
	props: Record<string, any>,
	children: any,
) {
	if (typeof Component !== 'function') return false;
	if (Component.name === 'QwikComponent') return false;
	// Svelte component renders fine by Solid as an empty string. The only way to detect
	// if this isn't a Solid but Svelte component is to unfortunately copy the check
	// implementation of the Svelte renderer.
	if (Component.toString().includes('$$payload')) return false;

	// There is nothing particularly special about Solid components. Basically they are just functions.
	// In general, components from other frameworks (eg, MDX, React, etc.) tend to render as "undefined",
	// so we take advantage of this trick to decide if this is a Solid component or not.

	let html: string | undefined;
	try {
		const result = await renderToStaticMarkup.call(this, Component, props, children, {
			// The purpose of check() is just to validate that this is a Solid component and not
			// React, etc. We should render in sync mode which should skip Suspense boundaries
			// or loading resources like external API calls.
			renderStrategy: 'sync' as RenderStrategy,
		});
		html = result.html;
	} catch {}

	return typeof html === 'string';
}

Domain

Subdomains

Frequently Asked Questions

What does check() do?
check() is a function in the astro codebase, defined in packages/integrations/solid/src/server.ts.
Where is check() defined?
check() is defined in packages/integrations/solid/src/server.ts at line 18.
What calls check()?
check() is called by 1 function(s): renderToStaticMarkup.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free