Home / Function/ importPlugin() — astro Function Reference

importPlugin() — astro Function Reference

Architecture documentation for the importPlugin() function in import-plugin-default.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  f09e2179_50ff_3fac_5815_65bfb23d4d9b["importPlugin()"]
  58892a04_421a_ce1a_f6f5_aaa947266446["import-plugin-default.ts"]
  f09e2179_50ff_3fac_5815_65bfb23d4d9b -->|defined in| 58892a04_421a_ce1a_f6f5_aaa947266446
  style f09e2179_50ff_3fac_5815_65bfb23d4d9b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/markdown/remark/src/import-plugin-default.ts lines 12–24

export async function importPlugin(p: string): Promise<unified.Plugin> {
	// Try import from this package first
	try {
		const importResult = await import(/* @vite-ignore */ p);
		return importResult.default;
	} catch {}

	// Try import from user project
	cwdUrlStr ??= pathToFileURL(path.join(process.cwd(), 'package.json')).toString();
	const resolved = pathToFileURL(require.resolve(p, { paths: [cwdUrlStr] })).toString();
	const importResult = await import(/* @vite-ignore */ resolved);
	return importResult.default;
}

Domain

Subdomains

Frequently Asked Questions

What does importPlugin() do?
importPlugin() is a function in the astro codebase, defined in packages/markdown/remark/src/import-plugin-default.ts.
Where is importPlugin() defined?
importPlugin() is defined in packages/markdown/remark/src/import-plugin-default.ts at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free