From 6885e60f74b8db02d87441c9f918f789ec124798 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 26 Jun 2023 16:33:26 -0500 Subject: [PATCH] fix(#7333): pass compressHTML to manifest --- .changeset/mean-spoons-tie.md | 5 +++++ packages/astro/src/core/app/index.ts | 4 +++- packages/astro/src/core/app/types.ts | 1 + packages/astro/src/core/build/plugins/plugin-ssr.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-spoons-tie.md diff --git a/.changeset/mean-spoons-tie.md b/.changeset/mean-spoons-tie.md new file mode 100644 index 000000000000..22d10d41fe50 --- /dev/null +++ b/.changeset/mean-spoons-tie.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Pass `compressHTML` setting to server adapters diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index ae0c3fb00e78..54fdc56c26cc 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -204,6 +204,7 @@ export class App { const url = new URL(request.url); const pathname = prependForwardSlash(this.removeBase(url.pathname)); const info = this.#routeDataToRouteInfo.get(routeData!)!; + const isCompressHTML = this.#manifest.compressHTML ?? false; // may be used in the future for handling rel=modulepreload, rel=icon, rel=manifest etc. const links = new Set(); const styles = createStylesheetElementSet(info.styles); @@ -252,7 +253,7 @@ export class App { page.onRequest as MiddlewareResponseHandler, apiContext, () => { - return renderPage({ mod, renderContext, env: this.#env, cookies: apiContext.cookies }); + return renderPage({ mod, renderContext, env: this.#env, cookies: apiContext.cookies, isCompressHTML }); } ); } else { @@ -261,6 +262,7 @@ export class App { renderContext, env: this.#env, cookies: apiContext.cookies, + isCompressHTML }); } Reflect.set(request, responseSentSymbol, true); diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 9af15bf50252..927da06d9771 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -38,6 +38,7 @@ export type SSRManifest = { routes: RouteInfo[]; site?: string; base?: string; + compressHTML?: boolean; assetsPrefix?: string; markdown: MarkdownRenderingOptions; renderers: SSRLoadedRenderer[]; diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index ebda7fb3e650..254037e59509 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -482,6 +482,7 @@ function buildManifest( routes, site: settings.config.site, base: settings.config.base, + compressHTML: settings.config.compressHTML, assetsPrefix: settings.config.build.assetsPrefix, markdown: settings.config.markdown, componentMetadata: Array.from(internals.componentMetadata),