Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add http-compression #951

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/wmr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"devcert": "^1.1.2",
"errorstacks": "^2.3.2",
"es-module-lexer": "^0.7.0",
"http-compression": "^1.0.4",
"jest": "^26.1.0",
"jest-puppeteer": "^5.0.4",
"kolorist": "^1.5.0",
Expand Down
107 changes: 0 additions & 107 deletions packages/wmr/src/lib/polkompress.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/wmr/src/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { normalizeOptions } from './lib/normalize-options.js';
import { getServerAddresses } from './lib/net-utils.js';
import { createServer } from 'http';
import { createHttp2Server } from './lib/http2.js';
import compression from './lib/polkompress.js';
import compression from 'http-compression';
import sirv from 'sirv';
import { formatBootMessage } from './lib/output-utils.js';

Expand Down Expand Up @@ -59,7 +59,7 @@ export default async function serve(options = {}) {

if (options.compress) {
const threshold = options.compress === true ? 1024 : options.compress;
app.use(compression({ threshold }));
app.use(compression({ brotli: false, threshold }));
}

if (options.middleware && options.middleware.length) {
Expand Down
4 changes: 2 additions & 2 deletions packages/wmr/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createServer } from 'http';
import { createHttp2Server } from './lib/http2.js';
import polka from 'polka';
import sirv from 'sirv';
import compression from './lib/polkompress.js';
import compression from 'http-compression';
import npmMiddleware from './lib/npm-middleware.js';
import WebSocketServer from './lib/websocket-server.js';
import * as kl from 'kolorist';
Expand Down Expand Up @@ -101,7 +101,7 @@ export default async function server({ cwd, root, overlayDir, middleware, http2,
if (compress) {
// @TODO: reconsider now that npm deps are compressed AOT
const threshold = compress === true ? 1024 : compress;
app.use(compression({ threshold, level: 4 }));
app.use(compression({ brotli: false, threshold, level: 4 }));
}

// Custom middlewares should always come first, similar to plugins
Expand Down
127 changes: 0 additions & 127 deletions packages/wmr/test/lib/polkompress.test.js

This file was deleted.

5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4335,6 +4335,11 @@ http-cache-semantics@^4.0.0:
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390"
integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==

http-compression@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/http-compression/-/http-compression-1.0.4.tgz#efa32f4751fa4deba010ba1a6a24e88b6b6a2434"
integrity sha512-LBOD+rkf1+y+jCeCzzGCpY/foA4nPz3NmX1VvjEDDYtFt1Prd1rQmGd4HQFFIcWM2PsXlVZvo/TvfAVAZP01eQ==

http-errors@1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f"
Expand Down