diff --git a/README.md b/README.md index e4a46242..7cb4aaa5 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/package.json b/package.json index 2671cd61..d527ad36 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", @@ -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", diff --git a/pipe.js b/pipe.js index 56c5d9d8..ada1a900 100644 --- a/pipe.js +++ b/pipe.js @@ -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') diff --git a/src/compressed-size.js b/src/compressed-size.js index e7846924..6657e051 100644 --- a/src/compressed-size.js +++ b/src/compressed-size.js @@ -1,5 +1,4 @@ const gzip = require('gzip-size') -const brotli = require('brotli-size') const getCompressedSize = (data, compression = 'gzip') => { let size @@ -7,9 +6,6 @@ const getCompressedSize = (data, compression = 'gzip') => { case 'gzip': size = gzip.sync(data) break - case 'brotli': - size = brotli.sync(data) - break case 'none': default: size = Buffer.byteLength(data) diff --git a/tests/index.js b/tests/index.js index bc298d5f..3f1c5561 100644 --- a/tests/index.js +++ b/tests/index.js @@ -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) @@ -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) diff --git a/tests/snapshots/index.js.md b/tests/snapshots/index.js.md index a1cd5a60..00eb6d4c 100644 --- a/tests/snapshots/index.js.md +++ b/tests/snapshots/index.js.md @@ -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)` diff --git a/tests/snapshots/index.js.snap b/tests/snapshots/index.js.snap index ed124eb2..b5e9cca9 100644 Binary files a/tests/snapshots/index.js.snap and b/tests/snapshots/index.js.snap differ