Skip to content

Commit

Permalink
[RRE-6393] remove brotli compression support
Browse files Browse the repository at this point in the history
  • Loading branch information
helgenlechner committed Oct 11, 2023
1 parent 6de086e commit 3b3b09e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 40 deletions.
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,6 @@ You can keep this array either in

By default, bundlesize `gzips` your build files before comparing.

If you are using `brotli` instead of gzip, you can specify that with each file:

```json
{
"files": [
{
"path": "./build/vendor.js",
"maxSize": "5 kB",
"compression": "brotli"
}
]
}
```

If you do not use any compression before sending your files to the client, you can switch compression off:

```json
Expand Down Expand Up @@ -191,7 +177,7 @@ You will need to supply an additional 5 environment variables.
- `CI_REPO_NAME` given the repo `https://github.com/myusername/myrepo` would be `myrepo`
- `CI_COMMIT_MESSAGE` the commit message
- `CI_COMMIT_SHA` the SHA of the CI commit, in [Jenkins](https://jenkins.io/) you would use `${env.GIT_COMMIT}`
- `CI=true` usually set automatically in CI environments
- `CI=true` usually set automatically in CI environments

(Ask me for help if you're stuck)

Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "bundlesize",
"version": "0.18.1",
"version": "1.0.0",
"description": "Keep your library size in check",
"repository": {
"type": "git",
"url": "git+https://github.com/siddharthkp/bundlesize.git"
"url": "git+https://github.com/chemmedia/bundlesize.git"
},
"main": "index.js",
"bin": {
Expand All @@ -16,10 +16,9 @@
"precommit": "lint-staged",
"t": "yarn test",
"test": "ava -v tests/index.js",
"test:old": "npm run test:default && npm run test:no-compression && npm run test:brotli-compression",
"test:old": "npm run test:default && npm run test:no-compression",
"test:default": "node index && cat pipe.js | node pipe --name pipe.js --max-size 1kB",
"test:no-compression": "cat pipe.js | node pipe --compression none --name pipe.js",
"test:brotli-compression": "cat pipe.js | node pipe --compression brotli --name pipe.js"
"test:no-compression": "cat pipe.js | node pipe --compression none --name pipe.js"
},
"keywords": [
"library",
Expand All @@ -37,7 +36,6 @@
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"brotli-size": "0.1.0",
"bytes": "^3.1.0",
"ci-env": "^1.4.0",
"commander": "^2.20.0",
Expand Down
2 changes: 1 addition & 1 deletion pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program
.option('-n, --name [name]', 'custom name for a file (lib.min.js)')
.option('-s, --max-size [maxSize]', 'maximum size threshold (3Kb)')
.option(
'-c, --compression [gzip|brotli|none]',
'-c, --compression [gzip|none]',
'specify which compression algorithm to use'
)
.option('--debug', 'run in debug mode')
Expand Down
4 changes: 0 additions & 4 deletions src/compressed-size.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
const gzip = require('gzip-size')
const brotli = require('brotli-size')

const getCompressedSize = (data, compression = 'gzip') => {
let size
switch (compression) {
case 'gzip':
size = gzip.sync(data)
break
case 'brotli':
size = brotli.sync(data)
break
case 'none':
default:
size = Buffer.byteLength(data)
Expand Down
22 changes: 8 additions & 14 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,43 @@ test.serial('2. fail: single file larger than limit', t => {
t.snapshot(stdout)
})

test.serial('3. pass: use brotli', t => {
const { stdout, exitCode } = run(3)
t.is(exitCode, 0)
t.snapshot(stdout)
})

test.serial('4. fail: dont use compression', t => {
test.serial('3. fail: dont use compression', t => {
const { stdout, exitCode } = run(4)
t.is(exitCode, 1)
t.snapshot(stdout)
})

test.serial('5. pass: custom config file', t => {
test.serial('4. pass: custom config file', t => {
const { stdout, exitCode } = run(5, '--config config/bundlesize.json')
t.is(exitCode, 0)
t.snapshot(stdout)
})

test.serial('6. pass: multiple files, both smaller than limit', t => {
test.serial('5. pass: multiple files, both smaller than limit', t => {
const { stdout, exitCode } = run(6)
t.is(exitCode, 0)
t.snapshot(stdout)
})

test.serial('7. fail: multiple files, both bigger than limit', t => {
test.serial('6. fail: multiple files, both bigger than limit', t => {
const { stdout, exitCode } = run(7)
t.is(exitCode, 1)
t.snapshot(stdout)
})

test.serial('8. fail: multiple files, 1 smaller + 1 bigger than limit', t => {
test.serial('7. fail: multiple files, 1 smaller + 1 bigger than limit', t => {
const { stdout, exitCode } = run(8)
t.is(exitCode, 1)
t.snapshot(stdout)
})

test.serial('9. pass: catch all js files', t => {
test.serial('8. pass: catch all js files', t => {
const { stdout, exitCode } = run(9)
t.is(exitCode, 0)
t.snapshot(stdout)
})

test.serial('10. pass: match by fuzzy name', t => {
test.serial('9. pass: match by fuzzy name', t => {
const { stdout, exitCode } = run(10)
t.is(exitCode, 0)
t.snapshot(stdout)
Expand Down Expand Up @@ -104,7 +98,7 @@ test.serial('10. pass: match by fuzzy name', t => {
test.serial
*/

test.skip('11. bug repro: bundlesize should dedup files', t => {
test.skip('10. bug repro: bundlesize should dedup files', t => {
const { stdout, exitCode } = run(11)
t.is(exitCode, 0) // this is failing
t.snapshot(stdout)
Expand Down
52 changes: 52 additions & 0 deletions tests/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,55 @@ Generated by [AVA](https://ava.li).
`PASS build/chunks/chunk-ch0nk.js: 270B < maxSize 300B (gzip) ␊
PASS build/vendor-ha5h.js: 270B < maxSize 300B (gzip)`

## 3. fail: dont use compression

> Snapshot 1
'FAIL file-4.js: 437B > maxSize 300B (no compression)'

## 4. pass: custom config file

> Snapshot 1
'PASS file-5.js: 270B < maxSize 300B (gzip)'

## 5. pass: multiple files, both smaller than limit

> Snapshot 1
`PASS file-61.js: 270B < maxSize 300B (gzip) ␊
PASS file-62.js: 270B < maxSize 300B (gzip)`

## 6. fail: multiple files, both bigger than limit

> Snapshot 1
`FAIL file-61.js: 270B > maxSize 200B (gzip) ␊
FAIL file-62.js: 270B > maxSize 200B (gzip)`

## 7. fail: multiple files, 1 smaller + 1 bigger than limit

> Snapshot 1
`PASS file-61.js: 270B < maxSize 300B (gzip) ␊
FAIL file-62.js: 270B > maxSize 200B (gzip)`

## 8. pass: catch all js files

> Snapshot 1
`PASS build/chunks/chunk-ch0nk.js: 270B < maxSize 300B (gzip) ␊
PASS build/vendor-ha5h.js: 270B < maxSize 300B (gzip)`

## 9. pass: match by fuzzy name

> Snapshot 1
`PASS build/vendor-ha5h.js: 270B < maxSize 350B (gzip) ␊
PASS build/chunks/chunk-ch0nk.js: 270B < maxSize 300B (gzip)`
Binary file modified tests/snapshots/index.js.snap
Binary file not shown.

0 comments on commit 3b3b09e

Please sign in to comment.