Repository: withastro/astro
File: packages/integrations/netlify/src/index.ts (TypeScript)

Code before:
		}

		const fallback = finalBuildOutput === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
		const redirects = createRedirectsFromAstroRoutes({
			config: _config,
			dir,
			routeToDynamicTargetMap: new Map(staticRedirects.map((route) => [route, fallback])),
			buildOutput,
			assets,
		});

		if (!redirects.empty()) {
			await appendFile(new URL('_redirects', outDir), `\n${redirects.print()}\n`);
		}
	}

	async function getFilesByGlob(
		include: Array<string> = [],
		exclude: Array<string> = [],
	): Promise<Array<URL>> {
		const files = await glob(include, {
			cwd: fileURLToPath(rootDir),
			absolute: true,
			ignore: exclude,
		});
		return files.map((file) => new URL(pathToFileURL(file), _config.root));
	}

	async function writeSSRFunction({
		notFoundContent,
		logger,
		root,
	}: {
		notFoundContent?: string;
		logger: AstroIntegrationLogger;
		root: URL;
	}) {
		const entry = new URL('./entry.mjs', ssrBuildDir());

		const _includeFiles = integrationConfig?.includeFiles || [];
		const _excludeFiles = integrationConfig?.excludeFiles || [];

		if (finalBuildOutput === 'server') {
			// Merge any includes from `vite.assetsInclude
			if (_config.vite.assetsInclude) {
				const mergeGlobbedIncludes = (globPattern: unknown) => {
					if (typeof globPattern === 'string') {
						const entries = glob.sync(globPattern).map((p) => pathToFileURL(p));
						extraFilesToInclude.push(...entries);
					} else if (Array.isArray(globPattern)) {
						for (const pattern of globPattern) {

Review comment (suggestion):
Since you passed `absolute: true`, there's no need to use `_config.root`. Plus, you could have used `rootDir` instead. 

https://www.npmjs.com/package/fast-glob#output-control

Code after:
		routes: IntegrationResolvedRoute[],
		dir: URL,
		buildOutput: HookParameters<'astro:config:done'>['buildOutput'],
		assets: HookParameters<'astro:build:done'>['assets'],
	) {
		// all other routes are handled by SSR
		const staticRedirects = routes.filter(
			(route) => route.type === 'redirect' && (route.redirect || route.redirectRoute),
		);

		// this is needed to support redirects to dynamic routes
		// on static. not sure why this is needed, but it works.
		for (const { pattern, redirectRoute } of staticRedirects) {
			const distURL = assets.get(pattern);
			if (!distURL && redirectRoute) {
				const redirectDistURL = assets.get(redirectRoute.pattern);
				if (redirectDistURL) {
					assets.set(pattern, redirectDistURL);
				}
			}
		}

		const fallback = finalBuildOutput === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
		const redirects = createRedirectsFromAstroRoutes({
			config: _config,
			dir,
			routeToDynamicTargetMap: new Map(staticRedirects.map((route) => [route, fallback])),
			buildOutput,
			assets,
		});

		if (!redirects.empty()) {
			await appendFile(new URL('_redirects', outDir), `\n${redirects.print()}\n`);
		}
	}

	async function getFilesByGlob(
		include: Array<string> = [],
		exclude: Array<string> = [],
	): Promise<Array<URL>> {
		const files = await glob(include, {
			cwd: fileURLToPath(rootDir),
			absolute: true,
			ignore: exclude,
		});
		return files.map((file) => pathToFileURL(file));
	}

	async function writeSSRFunction({
		notFoundContent,
		logger,