Skip to content

Commit

Permalink
feat: enable compression (#903)
Browse files Browse the repository at this point in the history
Text compression is not enabled in hono.
When we run a light house score on the sample app generated, we get 95
score.
<img width="406" alt="Screenshot 2024-09-26 at 16 09 15"
src="https://github.com/user-attachments/assets/8f00a15c-ac47-429c-97f7-025fcc0b9fe8">

Enabling compression along with the meta description fix in #904 gives
100/100.

---------

Co-authored-by: Daishi Kato <[email protected]>
  • Loading branch information
sarat1669 and dai-shi authored Sep 27, 2024
1 parent abc5d17 commit 67ede80
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/waku/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
import { createRequire } from 'node:module';
import { Hono } from 'hono';
import { compress } from 'hono/compress';
import { contextStorage } from 'hono/context-storage';
import { serve } from '@hono/node-server';
import { serveStatic } from '@hono/node-server/serve-static';
Expand Down Expand Up @@ -51,6 +52,9 @@ const { values, positionals } = parseArgs({
'experimental-partial': {
type: 'boolean',
},
'experimental-compress': {
type: 'boolean',
},
port: {
type: 'string',
short: 'p',
Expand Down Expand Up @@ -98,6 +102,9 @@ async function runDev() {
const honoEnhancer = config.unstable_honoEnhancer || ((app) => app);
const app = new Hono();
app.use(contextStorage());
if (values['experimental-compress']) {
app.use(compress());
}
app.use('*', runner({ cmd: 'dev', config, env: process.env as any }));
app.notFound((c) => {
// FIXME can we avoid hardcoding the public path?
Expand Down Expand Up @@ -144,6 +151,9 @@ async function runStart() {
import(pathToFileURL(path.resolve(distDir, DIST_ENTRIES_JS)).toString());
const app = new Hono();
app.use(contextStorage());
if (values['experimental-compress']) {
app.use(compress());
}
app.use('*', serveStatic({ root: path.join(distDir, DIST_PUBLIC) }));
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env as any }));
app.notFound((c) => {
Expand Down

0 comments on commit 67ede80

Please sign in to comment.