0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Pass compressHTML settings to manifest (#7488)

* fix(#7333): pass compressHTML to manifest

* chore: add compressHTML to astro:ssr-manifest test
This commit is contained in:
Nate Moore 2023-06-28 14:49:10 -05:00 committed by GitHub
parent e9a0fb502a
commit d3247851f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Pass `compressHTML` setting to server adapters

View file

@ -204,6 +204,7 @@ export class App {
const url = new URL(request.url); const url = new URL(request.url);
const pathname = prependForwardSlash(this.removeBase(url.pathname)); const pathname = prependForwardSlash(this.removeBase(url.pathname));
const info = this.#routeDataToRouteInfo.get(routeData!)!; 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. // may be used in the future for handling rel=modulepreload, rel=icon, rel=manifest etc.
const links = new Set<never>(); const links = new Set<never>();
const styles = createStylesheetElementSet(info.styles); const styles = createStylesheetElementSet(info.styles);
@ -252,7 +253,7 @@ export class App {
page.onRequest as MiddlewareResponseHandler, page.onRequest as MiddlewareResponseHandler,
apiContext, apiContext,
() => { () => {
return renderPage({ mod, renderContext, env: this.#env, cookies: apiContext.cookies }); return renderPage({ mod, renderContext, env: this.#env, cookies: apiContext.cookies, isCompressHTML });
} }
); );
} else { } else {
@ -261,6 +262,7 @@ export class App {
renderContext, renderContext,
env: this.#env, env: this.#env,
cookies: apiContext.cookies, cookies: apiContext.cookies,
isCompressHTML
}); });
} }
Reflect.set(request, responseSentSymbol, true); Reflect.set(request, responseSentSymbol, true);

View file

@ -38,6 +38,7 @@ export type SSRManifest = {
routes: RouteInfo[]; routes: RouteInfo[];
site?: string; site?: string;
base?: string; base?: string;
compressHTML?: boolean;
assetsPrefix?: string; assetsPrefix?: string;
markdown: MarkdownRenderingOptions; markdown: MarkdownRenderingOptions;
renderers: SSRLoadedRenderer[]; renderers: SSRLoadedRenderer[];

View file

@ -482,6 +482,7 @@ function buildManifest(
routes, routes,
site: settings.config.site, site: settings.config.site,
base: settings.config.base, base: settings.config.base,
compressHTML: settings.config.compressHTML,
assetsPrefix: settings.config.build.assetsPrefix, assetsPrefix: settings.config.build.assetsPrefix,
markdown: settings.config.markdown, markdown: settings.config.markdown,
componentMetadata: Array.from(internals.componentMetadata), componentMetadata: Array.from(internals.componentMetadata),

View file

@ -11,6 +11,7 @@ describe('astro:ssr-manifest', () => {
fixture = await loadFixture({ fixture = await loadFixture({
root: './fixtures/ssr-manifest/', root: './fixtures/ssr-manifest/',
output: 'server', output: 'server',
compressHTML: true,
adapter: testAdapter(), adapter: testAdapter(),
}); });
await fixture.build(); await fixture.build();
@ -25,4 +26,10 @@ describe('astro:ssr-manifest', () => {
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('#assets').text()).to.equal('["/_astro/index.a8a337e4.css"]'); 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;
});
}); });