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

Code before:
	 *
	 * @default {true}
	 */
	imageCDN?: boolean;

	/**
	 * If enabled, the adapter will save [static headers in the framework API file](https://docs.netlify.com/frameworks-api/#headers).
	 *
	 * Here the list of the headers that are added:
	 * - The CSP header of the static pages is added when CSP support is enabled.
	 */
	experimentalStaticHeaders?: boolean;
}

export default function netlifyIntegration(
	integrationConfig?: NetlifyIntegrationConfig,
): AstroIntegration {
	const isRunningInNetlify = Boolean(
		process.env.NETLIFY || process.env.NETLIFY_LOCAL || process.env.NETLIFY_DEV,
	);

	let _config: AstroConfig;
	let outDir: URL;
	let rootDir: URL;
	let astroMiddlewareEntryPoint: URL | undefined = undefined;
	let _experimentalStaticHeaders: Map<IntegrationResolvedRoute, Headers> | undefined = undefined;
	// Extra files to be merged with `includeFiles` during build
	const extraFilesToInclude: URL[] = [];
	// Secret used to verify that the caller is the astro-generated edge middleware and not a third-party
	const middlewareSecret = randomUUID();

	let finalBuildOutput: HookParameters<'astro:config:done'>['buildOutput'];

	const TRACE_CACHE = {};

	const ssrBuildDir = () => new URL('./.netlify/build/', rootDir);
	const ssrOutputDir = () => new URL('./.netlify/v1/functions/ssr/', rootDir);
	const middlewareOutputDir = () => new URL('.netlify/v1/edge-functions/middleware/', rootDir);

	const cleanFunctions = async () =>
		await Promise.all([
			emptyDir(middlewareOutputDir()),
			emptyDir(ssrOutputDir()),
			emptyDir(ssrBuildDir()),
		]);

	async function writeRedirects(
		routes: IntegrationResolvedRoute[],
		dir: URL,
		buildOutput: HookParameters<'astro:config:done'>['buildOutput'],
		assets: HookParameters<'astro:build:done'>['assets'],

Review comment (suggestion):
It's confusing having `_experimentalStaticHeaders` and `experimentalStaticHeaders`, one of which is a flag and the other a map of the actual headers. 

Code after:
	 *
	 * @default {true}
	 */
	imageCDN?: boolean;

	/**
	 * If enabled, the adapter will save [static headers in the framework API file](https://docs.netlify.com/frameworks-api/#headers).
	 *
	 * Here the list of the headers that are added:
	 * - The CSP header of the static pages is added when CSP support is enabled.
	 */
	experimentalStaticHeaders?: boolean;
}

export default function netlifyIntegration(
	integrationConfig?: NetlifyIntegrationConfig,
): AstroIntegration {
	const isRunningInNetlify = Boolean(
		process.env.NETLIFY || process.env.NETLIFY_LOCAL || process.env.NETLIFY_DEV,
	);

	let _config: AstroConfig;
	let outDir: URL;
	let rootDir: URL;
	let astroMiddlewareEntryPoint: URL | undefined = undefined;
	let staticHeadersMap: Map<IntegrationResolvedRoute, Headers> | undefined = undefined;
	// Extra files to be merged with `includeFiles` during build
	const extraFilesToInclude: URL[] = [];
	// Secret used to verify that the caller is the astro-generated edge middleware and not a third-party
	const middlewareSecret = randomUUID();

	let finalBuildOutput: HookParameters<'astro:config:done'>['buildOutput'];

	const TRACE_CACHE = {};

	const ssrBuildDir = () => new URL('./.netlify/build/', rootDir);
	const ssrOutputDir = () => new URL('./.netlify/v1/functions/ssr/', rootDir);
	const middlewareOutputDir = () => new URL('.netlify/v1/edge-functions/middleware/', rootDir);

	const cleanFunctions = async () =>
		await Promise.all([
			emptyDir(middlewareOutputDir()),
			emptyDir(ssrOutputDir()),
			emptyDir(ssrBuildDir()),
		]);

	async function writeRedirects(
		routes: IntegrationResolvedRoute[],
		dir: URL,
		buildOutput: HookParameters<'astro:config:done'>['buildOutput'],
		assets: HookParameters<'astro:build:done'>['assets'],