Home / File/ vite-plugin-server-islands.ts — astro Source File

vite-plugin-server-islands.ts — astro Source File

Architecture documentation for vite-plugin-server-islands.ts, a typescript file in the astro codebase. 6 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  1a4e9367_8808_ab57_d785_0978b31b0a7b["vite-plugin-server-islands.ts"]
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  2273eb38_2cc1_3ab6_58ce_6299d8f2ed92["../vite-plugin-astro/index.js"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> 2273eb38_2cc1_3ab6_58ce_6299d8f2ed92
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b
  57045b72_8cbd_6e93_7687_5176cbcd502d["magic-string"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> 57045b72_8cbd_6e93_7687_5176cbcd502d
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  1a4e9367_8808_ab57_d785_0978b31b0a7b --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 1a4e9367_8808_ab57_d785_0978b31b0a7b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import MagicString from 'magic-string';
import type { ConfigEnv, DevEnvironment, Plugin as VitePlugin } from 'vite';
import type { AstroPluginOptions } from '../../types/astro.js';
import type { AstroPluginMetadata } from '../../vite-plugin-astro/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../constants.js';

export const SERVER_ISLAND_MANIFEST = 'virtual:astro:server-island-manifest';
const RESOLVED_SERVER_ISLAND_MANIFEST = '\0' + SERVER_ISLAND_MANIFEST;

const serverIslandPlaceholderMap = "'$$server-islands-map$$'";
const serverIslandPlaceholderNameMap = "'$$server-islands-name-map$$'";

export function vitePluginServerIslands({ settings }: AstroPluginOptions): VitePlugin {
	let command: ConfigEnv['command'] = 'serve';
	let ssrEnvironment: DevEnvironment | null = null;
	const referenceIdMap = new Map<string, string>();
	const serverIslandMap = new Map();
	const serverIslandNameMap = new Map();
	return {
		name: 'astro:server-islands',
		enforce: 'post',
		config(_config, { command: _command }) {
			command = _command;
		},
		configureServer(server) {
			ssrEnvironment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
		},
		resolveId: {
			filter: {
				id: new RegExp(`^${SERVER_ISLAND_MANIFEST}$`),
			},
			handler() {
				return RESOLVED_SERVER_ISLAND_MANIFEST;
			},
		},
		load: {
			filter: {
				id: new RegExp(`^${RESOLVED_SERVER_ISLAND_MANIFEST}$`),
			},
			handler() {
				return {
					code: `export const serverIslandMap = ${serverIslandPlaceholderMap};\n\nexport const serverIslandNameMap = ${serverIslandPlaceholderNameMap};`,
				};
			},
		},

		transform: {
			filter: {
				id: {
					include: [
						// Allows server islands in astro and mdx files
						/\.(astro|mdx)$/,
						new RegExp(`^${RESOLVED_SERVER_ISLAND_MANIFEST}$`),
					],
				},
			},
			async handler(_code, id) {
				const info = this.getModuleInfo(id);

// ... (116 more lines)

Domain

Subdomains

Dependencies

  • ../core/constants.js
  • ../core/errors/index.js
  • ../types/astro.js
  • ../vite-plugin-astro/index.js
  • magic-string
  • vite

Frequently Asked Questions

What does vite-plugin-server-islands.ts do?
vite-plugin-server-islands.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in vite-plugin-server-islands.ts?
vite-plugin-server-islands.ts defines 1 function(s): vitePluginServerIslands.
What does vite-plugin-server-islands.ts depend on?
vite-plugin-server-islands.ts imports 6 module(s): ../core/constants.js, ../core/errors/index.js, ../types/astro.js, ../vite-plugin-astro/index.js, magic-string, vite.
Where is vite-plugin-server-islands.ts in the architecture?
vite-plugin-server-islands.ts is located at packages/astro/src/core/server-islands/vite-plugin-server-islands.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/server-islands).

Analyze Your Own Codebase

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

Try Supermodel Free