summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2023-06-28 14:49:10 -0500
committerGravatar GitHub <noreply@github.com> 2023-06-28 14:49:10 -0500
commitd3247851f04e911c134cfedc22db17b7d61c53d9 (patch)
tree82568cca26b2e689d406182900555e4f62ab732c
parente9a0fb502a118c180fb52943905535d9f56f5ba5 (diff)
downloadastro-d3247851f04e911c134cfedc22db17b7d61c53d9.tar.gz
astro-d3247851f04e911c134cfedc22db17b7d61c53d9.tar.zst
astro-d3247851f04e911c134cfedc22db17b7d61c53d9.zip
Pass `compressHTML` settings to manifest (#7488)
* fix(#7333): pass compressHTML to manifest * chore: add compressHTML to astro:ssr-manifest test
-rw-r--r--.changeset/mean-spoons-tie.md5
-rw-r--r--packages/astro/src/core/app/index.ts4
-rw-r--r--packages/astro/src/core/app/types.ts1
-rw-r--r--packages/astro/src/core/build/plugins/plugin-ssr.ts1
-rw-r--r--packages/astro/test/ssr-manifest.test.js7
5 files changed, 17 insertions, 1 deletions
diff --git a/.changeset/mean-spoons-tie.md b/.changeset/mean-spoons-tie.md
new file mode 100644
index 000000000..22d10d41f
--- /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 ae0c3fb00..54fdc56c2 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<never>();
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 9af15bf50..927da06d9 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 ebda7fb3e..254037e59 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),
diff --git a/packages/astro/test/ssr-manifest.test.js b/packages/astro/test/ssr-manifest.test.js
index cb876bde9..4e5521220 100644
--- a/packages/astro/test/ssr-manifest.test.js
+++ b/packages/astro/test/ssr-manifest.test.js
@@ -11,6 +11,7 @@ describe('astro:ssr-manifest', () => {
fixture = await loadFixture({
root: './fixtures/ssr-manifest/',
output: 'server',
+ compressHTML: true,
adapter: testAdapter(),
});
await fixture.build();
@@ -25,4 +26,10 @@ describe('astro:ssr-manifest', () => {
const $ = cheerio.load(html);
expect($('#assets').text()).to.equal('["/_astro/index.a8a337e4.css"]');
});
+
+ it('includes compressHTML', async () => {
+ const app = await fixture.loadTestAdapterApp();
+ expect(app.manifest).to.haveOwnProperty('compressHTML');
+ expect(app.manifest.compressHTML).to.be.true;
+ });
});