From d783078f7074a6aeb73d547035a0dc700c302fc7 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 13 Apr 2018 16:37:36 -0400 Subject: [PATCH 01/11] Move brotli-size to optionalDependencies --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ecec9008..0848a4a6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "license": "MIT", "dependencies": { "axios": "^0.17.0", - "brotli-size": "0.0.1", "bytes": "^3.0.0", "ci-env": "^1.4.0", "commander": "^2.11.0", @@ -49,6 +48,9 @@ "prettycli": "^1.4.3", "read-pkg-up": "^3.0.0" }, + "optionalDependencies": { + "brotli-size": "0.0.1" + }, "bundlesize": [ { "path": "./index.js", From 0387ea48c9baa6de182e8f4aa507e6eed0f1eece Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 13 Apr 2018 16:41:57 -0400 Subject: [PATCH 02/11] Add warning "Missing optional dependency" --- src/compressed-size.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compressed-size.js b/src/compressed-size.js index e7846924..90879c1c 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 @@ -8,7 +7,12 @@ const getCompressedSize = (data, compression = 'gzip') => { size = gzip.sync(data) break case 'brotli': - size = brotli.sync(data) + try { + const brotli = require('brotli-size') + size = brotli.sync(data) + } catch (e) { + console.warn('Missing optional dependency: brotli-size') + } break case 'none': default: From c9165fae8345424cfa7a468a8e4b60f19dda3296 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 14 Apr 2018 14:27:39 -0400 Subject: [PATCH 03/11] Bump brotli-size to 0.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0848a4a6..23b9c84a 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "read-pkg-up": "^3.0.0" }, "optionalDependencies": { - "brotli-size": "0.0.1" + "brotli-size": "0.0.2" }, "bundlesize": [ { From 52e72bdf3daf7d2ed34f175912a0d411af47bf92 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 14 Apr 2018 14:30:49 -0400 Subject: [PATCH 04/11] Use prettycli to warn --- src/compressed-size.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compressed-size.js b/src/compressed-size.js index 90879c1c..6d61f78d 100644 --- a/src/compressed-size.js +++ b/src/compressed-size.js @@ -1,3 +1,4 @@ +const { warn } = require('prettycli') const gzip = require('gzip-size') const getCompressedSize = (data, compression = 'gzip') => { @@ -11,7 +12,8 @@ const getCompressedSize = (data, compression = 'gzip') => { const brotli = require('brotli-size') size = brotli.sync(data) } catch (e) { - console.warn('Missing optional dependency: brotli-size') + warn(`Missing optional dependency. Install it with: + npm install --save brotli-size`) } break case 'none': From 589833a54076acfcca3f071c9c9ee1f7f27e49e9 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 23 Apr 2018 10:06:23 -0400 Subject: [PATCH 05/11] Change brotli-size to peerDependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 23b9c84a..b75aa819 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "prettycli": "^1.4.3", "read-pkg-up": "^3.0.0" }, - "optionalDependencies": { - "brotli-size": "0.0.2" + "peerDependencies": { + "brotli-size": ">=0.0.1" }, "bundlesize": [ { From 5e89752e034f9c8b8dd72798d6442cb0410fee01 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 23 Apr 2018 10:09:56 -0400 Subject: [PATCH 06/11] Add note about peer depdendency for brotli-size --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8ef592e6..1d224d17 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ npx bundlesize #### 1) Add the path and maxSize in your `package.json`. By default the gzipped size is tested. You can use the `compression` option to change this. (`gzip`, `brotli`, or `none`). +To use the `brotli` compression option, you must install the peer dependency: `npm install --save brotli-size` + ```json { "name": "your cool library", From 088e8f71ffe5ef63074c6a71f385c2ba0a281fab Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 23 Apr 2018 10:24:46 -0400 Subject: [PATCH 07/11] Remove brotli-size --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index b75aa819..03ec0f92 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,6 @@ "prettycli": "^1.4.3", "read-pkg-up": "^3.0.0" }, - "peerDependencies": { - "brotli-size": ">=0.0.1" - }, "bundlesize": [ { "path": "./index.js", From eecc3f95e000608694c5099ae8a1748bfa93ed5d Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 30 Apr 2018 11:51:33 -0400 Subject: [PATCH 08/11] Move try/catch around require --- src/compressed-size.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compressed-size.js b/src/compressed-size.js index 6d61f78d..0fd06307 100644 --- a/src/compressed-size.js +++ b/src/compressed-size.js @@ -1,5 +1,6 @@ const { warn } = require('prettycli') const gzip = require('gzip-size') +let brotli const getCompressedSize = (data, compression = 'gzip') => { let size @@ -9,12 +10,12 @@ const getCompressedSize = (data, compression = 'gzip') => { break case 'brotli': try { - const brotli = require('brotli-size') - size = brotli.sync(data) + brotli = require('brotli-size') } catch (e) { warn(`Missing optional dependency. Install it with: npm install --save brotli-size`) } + size = brotli ? brotli.sync(data) : 0 break case 'none': default: From 95f67ef821350e7a5df4682ef997313ea2448e21 Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Thu, 3 May 2018 15:18:29 +0530 Subject: [PATCH 09/11] run tests :/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2c1aee12..7719cd1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_script: - greenkeeper-lockfile-update script: - npm run lint + - npm test after_script: greenkeeper-lockfile-upload notifications: email: false From 4b3654c3e4ecff2b60f748538115849565c28261 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 3 May 2018 09:03:24 -0400 Subject: [PATCH 10/11] Throw if missing brotli-size dependency --- src/compressed-size.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compressed-size.js b/src/compressed-size.js index 0fd06307..b817fa49 100644 --- a/src/compressed-size.js +++ b/src/compressed-size.js @@ -12,10 +12,10 @@ const getCompressedSize = (data, compression = 'gzip') => { try { brotli = require('brotli-size') } catch (e) { - warn(`Missing optional dependency. Install it with: + throw new Error(`Missing optional dependency. Install it with: npm install --save brotli-size`) } - size = brotli ? brotli.sync(data) : 0 + size = brotli.sync(data) break case 'none': default: From 6653d732fddc7f7951c114d1716f679bf4a7b22e Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 5 May 2018 09:21:48 -0400 Subject: [PATCH 11/11] Remove unused warn import --- src/compressed-size.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compressed-size.js b/src/compressed-size.js index b817fa49..e676a290 100644 --- a/src/compressed-size.js +++ b/src/compressed-size.js @@ -1,4 +1,3 @@ -const { warn } = require('prettycli') const gzip = require('gzip-size') let brotli