Repository: withastro/astro
File: packages/astro/src/core/build/pipeline.ts (TypeScript)

Code before:
	 *
	 * @param staticBuildOptions
	 */
	static async retrieveManifest(
		staticBuildOptions: StaticBuildOptions,
		internals: BuildInternals,
	): Promise<SSRManifest> {
		const baseDirectory = getOutputDirectory(staticBuildOptions.settings);
		const manifestEntryUrl = new URL(
			`${internals.manifestFileName}?time=${Date.now()}`,
			baseDirectory,
		);
		const { manifest } = await import(manifestEntryUrl.toString());
		if (!manifest) {
			throw new Error(
				"Astro couldn't find the emitted manifest. This is an internal error, please file an issue.",
			);
		}

		const renderersEntryUrl = new URL(`renderers.mjs?time=${Date.now()}`, baseDirectory);
		const renderers = await import(renderersEntryUrl.toString());

		const middleware = internals.middlewareEntryPoint
			? async function () {
					const mod = await import(internals.middlewareEntryPoint.toString());
					return { onRequest: mod.onRequest };
				}
			: manifest.middleware;

		if (!renderers) {
			throw new Error(
				"Astro couldn't find the emitted renderers. This is an internal error, please file an issue.",
			);
		}
		return {
			...manifest,
			renderers: renderers.renderers as SSRLoadedRenderer[],
			middleware,
		};
	}

	headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'> {
		const {
			internals,
			manifest: { assetsPrefix, base },
			settings,
		} = this;
		const links = new Set<never>();
		const pageBuildData = getPageData(internals, routeData.route, routeData.component);
		const scripts = new Set<SSRElement>();
		const sortedCssAssets = pageBuildData?.styles

Review comment (suggestion):
```suggestion
					const mod = await import(internals.middlewareEntryPoint!.toString());
```
I think you need this to make the build pass since it's inside the function now

Code after:
	 *
	 * @param staticBuildOptions
	 */
	static async retrieveManifest(
		staticBuildOptions: StaticBuildOptions,
		internals: BuildInternals,
	): Promise<SSRManifest> {
		const baseDirectory = getOutputDirectory(staticBuildOptions.settings);
		const manifestEntryUrl = new URL(
			`${internals.manifestFileName}?time=${Date.now()}`,
			baseDirectory,
		);
		const { manifest } = await import(manifestEntryUrl.toString());
		if (!manifest) {
			throw new Error(
				"Astro couldn't find the emitted manifest. This is an internal error, please file an issue.",
			);
		}

		const renderersEntryUrl = new URL(`renderers.mjs?time=${Date.now()}`, baseDirectory);
		const renderers = await import(renderersEntryUrl.toString());

		const middleware = internals.middlewareEntryPoint
			? async function () {
					// @ts-expect-error: the compiler can't understand the previous check
					const mod = await import(internals.middlewareEntryPoint.toString());
					return { onRequest: mod.onRequest };
				}
			: manifest.middleware;

		if (!renderers) {
			throw new Error(
				"Astro couldn't find the emitted renderers. This is an internal error, please file an issue.",
			);
		}
		return {
			...manifest,
			renderers: renderers.renderers as SSRLoadedRenderer[],
			middleware,
		};
	}

	headElements(routeData: RouteData): Pick<SSRResult, 'scripts' | 'styles' | 'links'> {
		const {
			internals,
			manifest: { assetsPrefix, base },
			settings,
		} = this;
		const links = new Set<never>();
		const pageBuildData = getPageData(internals, routeData.route, routeData.component);
		const scripts = new Set<SSRElement>();